home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfacesHelp < prev    next >
Encoding:
Text File  |  1993-09-16  |  2.0 MB  |  56,725 lines  |  [TEXT/MPS ]

Text Truncated. Only the first 1MB is shown below. Download the file for the complete contents.
  1. æKY CopyrightNotice
  2. æC  Copyright Apple Computer, Inc. 1985-1990, All rights reserved.
  3. 411 - PInterfaces Help - MPW 3.2 Alpha Release.
  4. Friday, January 12, 1990 3:27:56 PM
  5.  
  6. æKY Help,PInterfacesHelp
  7. æKL AppleTalk.p
  8. Controls.p
  9. CursorCtl.p
  10. Desk.p
  11. DeskBus.p
  12. Devices.p
  13. Dialogs.p
  14. DisAsmLookup.p
  15. DiskInit.p
  16. Disks.p
  17. ErrMgr.p
  18. Errors.p
  19. Events.p
  20. Files.p
  21. FixMath.p
  22. Fonts.p
  23. Globals
  24. Graf3D.p
  25. HyperXCmd.p
  26. Lists.p
  27. Memory.p
  28. Menus.p
  29. Notification.p
  30. OSEvents.p
  31. OSUtils.p
  32. Packages.p
  33. Palettes.p
  34. Perf.p
  35. Picker.p
  36. Printing.p
  37. Quickdraw.p
  38. Resources.p
  39. Retrace.p
  40. ROMDefs.p
  41. SANE.p
  42. Scrap.p
  43. Script.p
  44. SCSI.p
  45. SCSIIntf.p
  46. SegLoad.p
  47. Serial.p
  48. ShutDown.p
  49. Signal.p
  50. Slots.p
  51. Sound.p
  52. Start.p
  53. Strings.p
  54. SysEqu.p
  55. TextEdit.p
  56. Timer.p
  57. ToolUtils.p
  58. Types.p
  59. Video.p
  60. Windows.p
  61.  
  62. æKY AppleTalk.p
  63. æKL AFPCommand
  64. ASPAbortOS
  65. ASPCloseAll
  66. ASPCloseSession
  67. ASPGetParms
  68. ASPGetStatus
  69. ASPOpenSession
  70. ASPUserCommand
  71. ASPUserWrite
  72. ATPAddRsp
  73. ATPCloseSocket
  74. ATPGetRequest
  75. ATPLoad
  76. ATPOpenSocket
  77. ATPReqCancel
  78. ATPRequest
  79. ATPResponse
  80. ATPRspCancel
  81. ATPSndRequest
  82. ATPSndRsp
  83. ATPUnload
  84. BuildBDS
  85. BuildDDPwds
  86. BuildLAPwds
  87. DDPCloseSocket
  88. DDPOpenSocket
  89. DDPRdCancel
  90. DDPRead
  91. DDPWrite
  92. GetBridgeAddress
  93. GetNodeAddress
  94. IsATPOpen
  95. IsMPPOpen
  96. LAPCloseProtocol
  97. LAPOpenProtocol
  98. LAPRdCancel
  99. LAPRead
  100. LAPWrite
  101. MPPClose
  102. MPPOpen
  103. NBPConfirm
  104. NBPExtract
  105. NBPLoad
  106. NBPLookup
  107. NBPRegister
  108. NBPRemove
  109. NBPSetEntity
  110. NBPSetNTE
  111. NBPUnload
  112. OpenXPP
  113. PAddResponse
  114. PAttachPH
  115. PCloseATPSkt
  116. PCloseSkt
  117. PConfirmName
  118. PDetachPH
  119. PGetRequest
  120. PKillGetReq
  121. PKillNBP
  122. PKillSendReq
  123. PLookupName
  124. PNSendRequest
  125. POpenATPSkt
  126. POpenSkt
  127. PRegisterName
  128. PRelRspCB
  129. PRelTCB
  130. PRemoveName
  131. PSendRequest
  132. PSendResponse
  133. PSetSelfSend
  134. PWriteDDP
  135. PWriteLAP
  136. RemoveHdlBlocks
  137.  
  138. ABByte
  139. ABCallType
  140. ABProtoType
  141. ABRecHandle
  142. ABRecPtr
  143. ABusRecord
  144. AddrBlock
  145. afpAddAPPL
  146. afpAddCmt
  147. afpAddIcon
  148. afpByteRangeLock
  149. AFPCommandBlock
  150. afpContLogin
  151. afpCopyFile
  152. afpDelete
  153. afpDirClose
  154. afpDirCreate
  155. afpDTClose
  156. afpDTOpen
  157. afpEnumerate
  158. afpFileCreate
  159. afpFlush
  160. afpForkClose
  161. afpForkFlush
  162. afpGetAPPL
  163. afpGetCmt
  164. afpGetDirParms
  165. afpGetFileParms
  166. afpGetFlDrParms
  167. afpGetForkParms
  168. afpGetIcon
  169. afpGetSInfo
  170. afpGetSParms
  171. afpGetVolParms
  172. afpGtIcnInfo
  173. afpLogin
  174. afpLogout
  175. afpMapID
  176. afpMapName
  177. afpMove
  178. afpOpenDir
  179. afpOpenFork
  180. afpOpenVol
  181. afpRead
  182. afpRename
  183. afpRmvAPPL
  184. afpRmvCmt
  185. afpSetDirParms
  186. afpSetFileParms
  187. afpSetFlDrParms
  188. afpSetForkParms
  189. afpSetVolParms
  190. afpVolClose
  191. afpWrite
  192. ATPaddrBlock
  193. ATPAddRsp
  194. ATPAddRsp
  195. ATPaKillQEl
  196. ATPatpFlags
  197. ATPatpSocket
  198. ATPbdsPointer
  199. ATPbdsSize
  200. ATPbitMap
  201. ATPcsCode
  202. atpEOMvalue
  203. ATPioCompletion
  204. ATPioRefNum
  205. ATPioResult
  206. ATPnumOfBuffs
  207. ATPnumOfResps
  208. ATPParamBlock
  209. ATPPBPtr
  210. atpProto
  211. ATPreqLength
  212. ATPreqPointer
  213. ATPreqTID
  214. ATPretryCount
  215. ATPrspNum
  216. atpSendChkvalue
  217. atpSize
  218. atpSTSvalue
  219. atpTIDValidvalue
  220. ATPtimeOutVal
  221. ATPtransID
  222. ATPuserData
  223. atpXOvalue
  224. BDSElement
  225. BDSPtr
  226. BDSType
  227. BitMapType
  228. DDPchecksumFlag
  229. DDPlistener
  230. ddpProto
  231. ddpSize
  232. DDPsocket
  233. DDPwdsPointer
  234. DDPWrite
  235. DDPWrite
  236. EntityName
  237. EntityPtr
  238. LAPAdrBlock
  239. LAPhandler
  240. lapProto
  241. LAPprotType
  242. lapSize
  243. LAPwdsPointer
  244. MPPcsCode
  245. MPPioCompletion
  246. MPPioRefNum
  247. MPPioResult
  248. MPPParamBlock
  249. MPPParmType
  250. MPPPBPtr
  251. NamesTableEntry
  252. NBPconfirmAddr
  253. NBPcount
  254. NBPentityPtr
  255. NBPinterval
  256. NBPmaxToGet
  257. NBPnewSocket
  258. NBPnKillQEl
  259. NBPntQElPtr
  260. NBPnumGotten
  261. nbpProto
  262. NBPretBuffPtr
  263. NBPretBuffSize
  264. nbpSize
  265. NBPverifyFlag
  266. OpenXPP
  267. OpenXPP
  268. RetransType
  269. scbMemSize
  270. Str32
  271. tATPAddRsp
  272. tATPGetRequest
  273. tATPRequest
  274. tATPResponse
  275. tATPSdRsp
  276. tATPSndRequest
  277. tDDPRead
  278. tDDPWrite
  279. tLAPRead
  280. tLAPWrite
  281. tNBPConfirm
  282. tNBPLookup
  283. tNBPRegister
  284. WDSElement
  285. XPPEndPrmType
  286. xppFlagClr
  287. xppFlagSet
  288. xppLoadedBit
  289. XPPParamBlock
  290. XPPParmBlkPtr
  291. XPPPrmBlkType
  292. xppRefNum
  293. XPPSubPrmType
  294. xppUnitNum
  295.  
  296. æKY XPPEndPrmType
  297. æFp AppleTalk.p
  298. æT TYPE
  299. æC XPPEndPrmType = (AFPLoginPrm,ASPEndPrm);
  300.  
  301. æKY XPPParmBlkPtr,XPPParamBlock
  302. æFp AppleTalk.p
  303. æT TYPE
  304. æC XPPParmBlkPtr = ^XPPParamBlock;
  305. XPPParamBlock = PACKED RECORD
  306.    qLink: QElemPtr;                                    {next queue entry}
  307.    qType: INTEGER;                                     {queue type}
  308.    ioTrap: INTEGER;                                    {routine trap}
  309.    ioCmdAddr: Ptr;                                     {routine address}
  310.    ioCompletion: ProcPtr;                              {completion routine}
  311.    ioResult: OSErr;                                    {result code}
  312.    cmdResult: LONGINT;                                 {command result(ATP user bytes)}
  313.    ioVRefNum: INTEGER;                                 {volume reference or drive 
  314.                                                         number}
  315.    ioRefNum: INTEGER;                                  {driver reference number}
  316.    csCode: INTEGER;                                    {call command code}
  317.    CASE XPPPrmBlkType OF
  318.      ASPAbortPrm:
  319.        (abortSCBPtr: Ptr);                             {SCB pointer for AbortOS}
  320.      ASPSizeBlk:
  321.        (aspMaxCmdSize: INTEGER;                        {for SPGetParms}
  322.        aspQuantumSize: INTEGER;                        {for SPGetParms}
  323.        numSesss: INTEGER);                             {for SPGetParms}
  324.      XPPPrmBlk:
  325.        (sessRefnum: INTEGER;                           {offset to session refnum}
  326.        aspTimeout: Byte;                               {timeout for ATP}
  327.        aspRetry: Byte;                                 {retry count for ATP}
  328.        CASE XPPSubPrmType OF
  329.          ASPOpenPrm:
  330.            (serverAddr: AddrBlock;                     {server address block}
  331.            scbPointer: Ptr;                            {SCB pointer}
  332.            attnRoutine: Ptr);                          {attention routine pointer}
  333.          ASPSubPrm:
  334.            (cbSize: INTEGER;                           {command block size}
  335.            cbPtr: Ptr;                                 {command block pointer}
  336.            rbSize: INTEGER;                            {reply buffer size}
  337.            rbPtr: Ptr;                                 {reply buffer pointer}
  338.            CASE XPPEndPrmType OF
  339.              AFPLoginPrm:
  340.                (afpAddrBlock: AddrBlock;               {address block in AFP login}
  341.                afpSCBPtr: Ptr;                         {SCB pointer in AFP login}
  342.                afpAttnRoutine: Ptr);                   {Attn routine pointer in AFP 
  343.                                                         login}
  344.              ASPEndPrm:
  345.                (wdSize: INTEGER;                       {write data size}
  346.                wdPtr: Ptr;                             {write data pointer}
  347.                ccbStart: ARRAY [0..295] OF Byte)));    {afpWrite max size = 296, else 
  348.                                                         150}
  349.    END;
  350.  
  351. æKY ATPPBPtr,ATPParamBlock
  352. æFp AppleTalk.p
  353. æT TYPE
  354. æC ATPPBPtr = ^ATPParamBlock;
  355. ATPParamBlock = PACKED RECORD
  356.    qLink: QElemPtr;                                    {next queue entry}
  357.    qType: INTEGER;                                     {queue type}
  358.    ioTrap: INTEGER;                                    {routine trap}
  359.    ioCmdAddr: Ptr;                                     {routine address}
  360.    ioCompletion: ProcPtr;                              {completion routine}
  361.    ioResult: OSErr;                                    {result code}
  362.    userData: LONGINT;                                  {ATP user bytes}
  363.    reqTID: INTEGER;                                    {request transaction ID}
  364.    ioRefNum: INTEGER;                                  {driver reference number}
  365.    csCode: INTEGER;                                    {Call command code 
  366.                                                         automatically set}
  367.    atpSocket: Byte;                                    {currBitMap or socket number}
  368.    atpFlags: Byte;                                     {control information}
  369.    addrBlock: AddrBlock;                               {source/dest. socket address}
  370.    reqLength: INTEGER;                                 {request/response length}
  371.    reqPointer: Ptr;                                    {-> request/response data}
  372.    bdsPointer: Ptr;                                    {-> response BDS}
  373.    CASE MPPParmType OF
  374.      SendRequestParm:
  375.        (numOfBuffs: Byte;                              {number of responses expected}
  376.        timeOutVal: Byte;                               {timeout interval}
  377.        numOfResps: Byte;                               {number of responses 
  378.                                                         actually received}
  379.        retryCount: Byte;                               {number of retries}
  380.        intBuff: INTEGER);                              {used internally for 
  381.                                                         NSendRequest}
  382.      SendResponseParm:
  383.        (filler0: Byte;                                 {numOfBuffs}
  384.        bdsSize: Byte;                                  {number of BDS elements}
  385.        transID: INTEGER);                              {transaction ID}
  386.      GetRequestParm:
  387.        (bitMap: Byte;                                  {bit map}
  388.        filler1: Byte);
  389.      AddResponseParm:
  390.        (rspNum: Byte;                                  {sequence number}
  391.        filler2: Byte);
  392.      KillSendReqParm:
  393.        (aKillQEl: Ptr);                                {ptr to Q element to cancel}
  394.    END;
  395.  
  396. æKY XPPPrmBlkType
  397. æFp AppleTalk.p
  398. æT TYPE
  399. æC XPPPrmBlkType = (XPPPrmBlk,ASPSizeBlk,ASPAbortPrm);
  400.  
  401. æKY XPPSubPrmType
  402. æFp AppleTalk.p
  403. æT TYPE
  404. æC XPPSubPrmType = (ASPOpenPrm,ASPSubPrm);
  405.  
  406. æKY MPPParmType
  407. æFp AppleTalk.p
  408. æT TYPE
  409. æC MPPParmType = (LAPWriteParm,AttachPHParm,DetachPHParm,OpenSktParm,CloseSktParm,
  410.    WriteDDPParm,OpenATPSktParm,CloseATPSktParm,SendRequestParm,GetRequestParm,
  411.    SendResponseParm,AddResponseParm,RelTCBParm,RelRspCBParm,RegisterNameParm,
  412.    LookupNameParm,ConfirmNameParm,RemoveNameParm,SetSelfSendParm,NSendRequestParm,
  413.    KillSendReqParm,KillGetReqParm,KillNBPParm);
  414.  
  415. æKY MPPParamBlock,MPPPBPtr
  416. æFp AppleTalk.p
  417. æT TYPE
  418. æC MPPPBPtr = ^MPPParamBlock;
  419. MPPParamBlock = PACKED RECORD
  420.    qLink: QElemPtr;                                    {next queue entry}
  421.    qType: INTEGER;                                     {queue type}
  422.    ioTrap: INTEGER;                                    {routine trap}
  423.    ioCmdAddr: Ptr;                                     {routine address}
  424.    ioCompletion: ProcPtr;                              {completion routine}
  425.    ioResult: OSErr;                                    {result code}
  426.    ioNamePtr: StringPtr;                               {->filename}
  427.    ioVRefNum: INTEGER;                                 {volume reference or drive 
  428.                                                         number}
  429.    ioRefNum: INTEGER;                                  {driver reference number}
  430.    csCode: INTEGER;                                    {call command code AUTOMATICALLY 
  431.                                                         set}
  432.    CASE MPPParmType OF
  433.      LAPWriteParm:
  434.        (filler0: INTEGER;
  435.        wdsPointer: Ptr);                               {->Write Data Structure}
  436.      AttachPHParm,DetachPHParm:
  437.        (protType: Byte;                                {ALAP Protocol Type}
  438.        filler1: Byte;
  439.        handler: Ptr);                                  {->protocol handler routine}
  440.      OpenSktParm,CloseSktParm,WriteDDPParm:
  441.        (socket: Byte;                                  {socket number}
  442.        checksumFlag: Byte;                             {checksum flag}
  443.        listener: Ptr);                                 {->socket listener routine}
  444.      RegisterNameParm,LookupNameParm,ConfirmNameParm,RemoveNameParm:
  445.        (interval: Byte;                                {retry interval}
  446.        count: Byte;                                    {retry count}
  447.        entityPtr: Ptr;                                 {->names table element or 
  448.                                                         ->entity name}
  449.        CASE MPPParmType OF
  450.          RegisterNameParm:
  451.            (verifyFlag: Byte;                          {set if verify needed}
  452.            filler3: Byte);
  453.          LookupNameParm:
  454.            (retBuffPtr: Ptr;                           {->return buffer}
  455.            retBuffSize: INTEGER;                       {return buffer size}
  456.            maxToGet: INTEGER;                          {matches to get}
  457.            numGotten: INTEGER);                        {matched gotten}
  458.          ConfirmNameParm:
  459.            (confirmAddr: AddrBlock;                    {->entity}
  460.            newSocket: Byte;                            {socket number}
  461.            filler4: Byte));
  462.      SetSelfSendParm:
  463.        (newSelfFlag: Byte;                             {self-send toggle flag}
  464.        oldSelfFlag: Byte);                             {previous self-send state}
  465.      KillNBPParm:
  466.        (nKillQEl: Ptr);                                {ptr to Q element to cancel}
  467.    END;
  468.  
  469. æKY ABusRecord,ABRecPtr,ABRecHandle
  470. æFp AppleTalk.p
  471. æT TYPE
  472. æC ABRecPtr = ^ABusRecord;
  473. ABRecHandle = ^ABRecPtr;
  474. ABusRecord = RECORD
  475.    abOpcode: ABCallType;
  476.    abResult: INTEGER;
  477.    abUserReference: LONGINT;
  478.    CASE ABProtoType OF
  479.      lapProto:
  480.        (lapAddress: LAPAdrBlock;
  481.        lapReqCount: INTEGER;
  482.        lapActCount: INTEGER;
  483.        lapDataPtr: Ptr);
  484.      ddpProto:
  485.        (ddpType: Byte;
  486.        ddpSocket: Byte;
  487.        ddpAddress: AddrBlock;
  488.        ddpReqCount: INTEGER;
  489.        ddpActCount: INTEGER;
  490.        ddpDataPtr: Ptr;
  491.        ddpNodeID: Byte);
  492.      nbpProto:
  493.        (nbpEntityPtr: EntityPtr;
  494.        nbpBufPtr: Ptr;
  495.        nbpBufSize: INTEGER;
  496.        nbpDataField: INTEGER;
  497.        nbpAddress: AddrBlock;
  498.        nbpRetransmitInfo: RetransType);
  499.      atpProto:
  500.        (atpSocket: Byte;
  501.        atpAddress: AddrBlock;
  502.        atpReqCount: INTEGER;
  503.        atpDataPtr: Ptr;
  504.        atpRspBDSPtr: BDSPtr;
  505.        atpBitmap: BitMapType;
  506.        atpTransID: INTEGER;
  507.        atpActCount: INTEGER;
  508.        atpUserData: LONGINT;
  509.        atpXO: BOOLEAN;
  510.        atpEOM: BOOLEAN;
  511.        atpTimeOut: Byte;
  512.        atpRetries: Byte;
  513.        atpNumBufs: Byte;
  514.        atpNumRsp: Byte;
  515.        atpBDSSize: Byte;
  516.        atpRspUData: LONGINT;
  517.        atpRspBuf: Ptr;
  518.        atpRspSize: INTEGER);
  519.    END;
  520. _______________________________________________________________________________
  521.  
  522. »CALLING THE APPLETALK MANAGER FROM PASCAL
  523. _______________________________________________________________________________
  524.  
  525. This section discusses how to use the AppleTalk Manager from Pascal. Equivalent
  526. assembly-language information is given in the “Calling the AppleTalk Manager from
  527. Assembly Language” section.
  528.  
  529. You can execute many AppleTalk Manager routines either synchronously (meaning that
  530. the application can’t continue until the routine is completed) or asynchronously
  531. (meaning that the application is free to perform other tasks while the routine is
  532. being executed).
  533.  
  534. When an application calls an AppleTalk Manager routine asynchronously, an I/O request
  535. is placed in the appropriate driver’s I/O queue, and control returns to the calling
  536. program—possibly even before the actual I/O is completed. Requests are taken from the
  537. queue one at a time, and processed; meanwhile, the calling program is free to work on
  538. other things.
  539.  
  540. The routines that can be executed asynchronously contain a Boolean parameter called
  541. async. If async is TRUE, the call is executed asynchronously; otherwise the call is
  542. executed synchronously. Every time an asynchronous routine call is completed, the
  543. AppleTalk Manager posts a network event. The message field of the event record will
  544. contain a handle to the parameter block that was used to make that call.
  545.  
  546. Most AppleTalk Manager routines return an integer result code of type OSErr. Each
  547. routine description lists all of the applicable result codes generated by the AppleTalk
  548. Manager, along with a short description of what the result code means. Lengthier
  549. explanations of all the result codes can be found in the summary at the end of the
  550. chapter. Result codes from other parts of the Operating System may also be returned.
  551. (See Appendix A for a list of all result codes.)
  552.  
  553. Many Pascal calls to the AppleTalk Manager require information passed in a parameter
  554. block of type ABusRecord. The exact content of an ABusRecord depends on the protocol
  555. being called:
  556.  
  557. TYPE  ABProtoType  =  (lapProto,ddpProto,nbpProto,atpProto);
  558.       ABusRecord   =  RECORD
  559.                         abOpcode:        ABCallType; {type of call}
  560.                         abResult:        INTEGER;    {result code}
  561.                         abUserReference: LONGINT;    {for your use}
  562.                         CASE ABProtoType OF
  563.                           lapProto:
  564.                             . . .     {ALAP parameters}
  565.                           ddpProto:
  566.                             . . .     {DDP parameters}
  567.                           nbpProto:
  568.                             . . .     {NBP parameters}
  569.                           atpProto:
  570.                             . . .     {ATP parameters}
  571.                         END;
  572.                       END;
  573.  
  574.       ABRecPtr     = ^ABusRecord;
  575.       ABRecHandle  = ^ABRecPtr;
  576.  
  577. The value of the abOpcode field is inserted by the AppleTalk Manager when the call is
  578. made, and is always a member of the following set:
  579.  
  580. TYPE  ABCallType = (tLAPRead,tLAPWrite,tDDPRead,tDDPWrite,tNBPLookup,
  581.                     tNBPConfirm,tNBPRegister,tATPSndRequest,
  582.                     tATPGetRequest,tATPSdRsp,tATPAddRsp,tATPRequest,
  583.                     tATPRespond);
  584.  
  585. The abUserReference field is available for use by the calling program in any way it
  586. wants. This field isn’t used by the AppleTalk Manager routines or drivers.
  587.  
  588. The size of an ABusRecord data structure in bytes is given by one of the following
  589. constants:
  590.  
  591. CONST  lapSize = 20;
  592.        ddpSize = 26;
  593.        nbpSize = 26;
  594.        atpSize = 56;
  595.  
  596. Variables of type ABusRecord must be allocated in the heap with Memory Manager NewHandle
  597. calls. For example:
  598.  
  599.   myABRecord := ABRecHandle(NewHandle(ddpSize))
  600.  
  601. Warning:  These Memory Manager calls can’t be made inside interrupts.
  602.  
  603. Routines that are executed asynchronously return control to the calling program with
  604. the result code noErr as soon as the call is placed in the driver’s I/O queue. This
  605. isn’t an indication of successful call completion; it simply indicates that the call
  606. was successfully queued to the appropriate driver. To determine when the call is
  607. actually completed, you can either check for a network event or poll the abResult
  608. field of the call’s ABusRecord. The abResult field, set to 1 when the call is made,
  609. receives the actual result code upon completion of the call.
  610.  
  611. Warning:  A data structure of type ABusRecord is often used by the AppleTalk
  612.           Manager during an asynchronous call, and so is locked by the
  613.           AppleTalk Manager. Don’t attempt to unlock or use such a variable.
  614.  
  615. Each routine description includes a list of the ABusRecord fields affected by the
  616. routine. The arrow next to each field name indicates whether it’s an input, output,
  617. or input/output parameter:
  618.  
  619. Arrow    Meaning
  620.   -->    Parameter is passed to the routine
  621.   <--    Parameter is returned by the routine
  622.   <->    Parameter is passed to and returned by the routine
  623.  
  624.  
  625. æKY ABByte
  626. æFp AppleTalk.p
  627. æT TYPE
  628. æC ABByte = 1..127;
  629.  
  630. æKY ABCallType,tLAPRead,tLAPWrite,tDDPRead,tDDPWrite,tNBPLookup,tNBPConfirm,tNBPRegister,tATPSndRequest,tATPGetRequest,tATPSdRsp,tATPAddRsp,tATPRequest,tATPResponse
  631. æFp Appletalk.p
  632. æC ABCallType = (tLAPRead,tLAPWrite,tDDPRead,tDDPWrite,tNBPLookup,tNBPConfirm,
  633. tNBPRegister,tATPSndRequest,tATPGetRequest,tATPSdRsp,tATPAddRsp,tATPRequest,
  634. tATPResponse);
  635.  
  636. æKY ABProtoType,lapProto,ddpProto,nbpProto,atpProto
  637. æFp Appletalk.p
  638. æC ABProtoType = (lapProto,ddpProto,nbpProto,atpProto);
  639.  
  640. æKY AddrBlock
  641. æFp Appletalk.p
  642. æT PACKED RECORD
  643. æC AddrBlock = PACKED RECORD
  644.    aNet: INTEGER;
  645.    aNode: Byte;
  646.    aSocket: Byte;
  647.    END;
  648.  
  649. æKY afpAddAPPL
  650. æFp Appletalk.p
  651. æC afpAddAPPL = 53; {AFPCall command codes}
  652.  
  653. æKY afpAddCmt
  654. æFp Appletalk.p
  655. æC afpAddCmt = 56; {AFPCall command codes}
  656.  
  657. æKY afpAddIcon
  658. æFp Appletalk.p
  659. æC afpAddIcon = 192; {Special code for ASP Write commands}
  660.  
  661. æKY afpByteRangeLock
  662. æFp Appletalk.p
  663. æC afpByteRangeLock = 1; {AFPCall command codes}
  664.  
  665. æKY AFPCommand
  666. æFp Appletalk.p
  667. æT FUNCTION
  668. æD FUNCTION AFPCommand(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  669. æDT myVariable := AFPCommand(thePBptr,async);
  670. æRI AFPCommand function  V-542
  671. æC 
  672. »AFPCall Function
  673.  
  674. The AFPCall function can have one of the following command formats.
  675.  
  676.   •  General
  677.   •  Login
  678.   •  AFPWrite
  679.   •  AFPRead
  680.  
  681. »General Command Format
  682.  
  683. FUNCTION AFPCommand (xParamBlock: XPPParmBlkPtr; async: BOOLEAN) : OSErr;
  684.  
  685. Parameter block
  686.   -->    18    cmdResult   long word  AFP command result
  687.   -->    26    csCode      word       Always AFPCall
  688.   -->    28    sessRefnum  word       Session reference number
  689.   -->    30    aspTimeout  byte       Retry interval in seconds
  690.   -->    32    cbSize      word       Command buffer size
  691.   -->    34    cbPtr       pointer    Command buffer
  692.   <->    38    rbSize      word       Reply buffer size and reply size
  693.   -->    40    rbPtr       pointer    Reply buffer pointer
  694.   <->    44    wdSize      word       Write data size
  695.   -->    46    wdPtr       pointer    Write data pointer
  696.   -->    50    ccbStart    record     Start of memory for CCB
  697.  
  698. The general command format for the AFPCall function passes an AFP command to the
  699. server.  This format is used for all AFP calls except AFPLogin, AFPRead, and AFPWrite.
  700.   Note that from Pascal this call is referred to as AFPCommand.
  701.  
  702. CmdResult is four bytes of data returned from the server containing an indication of
  703. the result of the AFP command.
  704.  
  705. SessRefnum is the session reference number returned in the AFPLogin call.
  706.  
  707. ASPTimeOut is the interval in seconds between retries of the call by the driver.
  708.  
  709. CBSize is the size in bytes of the block of data that contains the command to be sent
  710. to the server on the session. The size of the command block must not exceed the value
  711. of aspMaxCmdSize returned by the ASPGetParms call.
  712.  
  713. CBPtr points to start of the block of data (command block) containing the command
  714. that is to be sent to the server on the session.  The first byte of the command block
  715. must contain the AFP command byte.  Subsequent bytes in the command buffer contain
  716. the  parameters associated with the command as defined in the AFP document.
  717.  
  718. RBSize is passed and indicates the size of the reply buffer in bytes expected by the
  719. command. RBSize is also returned and indicates the size of the reply that was actually
  720. returned.
  721.  
  722. RBPtr points to the reply buffer.
  723.  
  724. WDSize is the size of data to be written to the server (only used if the command is
  725. one that is mapped to an ASPUserWrite).
  726.  
  727. WDPtr points to the write data buffer (only used if the command is one that is mapped
  728. to an ASPUserWrite).
  729.  
  730. CCBStart is the start of the memory to be used by the .XPP driver for the command
  731. control block.  The size of this block is equal to a maximum of 296 bytes.  To determine
  732. the exact requirement refer to the CCB Sizes section of this document.
  733.  
  734. Result codes    aspParamErr       Invalid session number; session has
  735.                                   been closed
  736.                 aspSizeErr        Command block size is bigger than MaxCmdSize
  737.                 aspSessClosed     Session is closing
  738.                 aspBufTooSmall    Reply is bigger than response buffer or
  739.                                   buffer will be filled, data will be truncated
  740.                 afpParmError      AFP command block size is equal to zero.
  741.                                   This error will also be returned if the
  742.                                   command byte in the command block is equal
  743.                                   to 0 or $FF (255) or GetSrvrStatus (15).
  744.  
  745. »Login Command Format
  746.  
  747. The AFP login command executes a series of AFP operations as defined in the AFP Draft
  748. Proposal.  For further information, refer to the AFP document.
  749.  
  750. FUNCTION AFPCommand (xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  751.  
  752. Parameter block
  753.   -->    18    cmdResult       long word  AFP command result
  754.   -->    26    csCode          word       Always AFPCall
  755.   -->    28    sessRefnum      word       Session reference number
  756.   -->    30    aspTimeout      byte       Retry interval in seconds
  757.   -->    31    aspRetry        byte       Number of retries
  758.   -->    32    cbSize          word       Command buffer size
  759.   -->    34    cbPtr           pointer    Command buffer
  760.   <->    38    rbSize          word       Reply buffer size and reply size
  761.   -->    40    rbPtr           pointer    Reply buffer pointer
  762.   -->    44    afpAddrBlock    long word  Server address block
  763.   <->    48    afpSCBPtr       pointer    SCB pointer
  764.   <->    52    afpAttnRoutine  pointer    Attention routine pointer
  765.   -->    50    ccbStart        record     Start of command control block
  766.  
  767. CmdResult is four bytes of data returned from the server containing an indication of
  768. the result of the AFP command.
  769.  
  770. SessRefnum is the session reference number (returned by the AFPLogin call).
  771.  
  772. ASPTimeOut is the interval in seconds between retries of the call.
  773.  
  774. ASPRetry is the number of retries that will be attempted.
  775.  
  776. CBSize is the size in bytes of the block data that contains the command to be sent to
  777. the server on the session. The size of the command block must not exceed the value of
  778. aspMaxCmdSize returned by the ASPGetParms call.
  779.  
  780. CBPtr points to the block of data (command block) containing the AFP login command
  781. that is to be sent to the server on the session.  The first byte of the command block
  782. must be the AFP login command byte.  Subsequent bytes in the command buffer contain
  783. the parameters associated with the command.
  784.  
  785. RBSize is passed and indicates the size of the reply buffer in bytes expected by the
  786. command.  RBSize is also returned and indicates the size of the reply that was actually
  787. returned.
  788.  
  789. RBPtr points to the reply buffer.
  790.  
  791. AFPServerAddr is the network identifier or address of the socket on which the server
  792. is listening.
  793.  
  794. AFPSCBPointer points to a locked block of data for the session control block
  795. (SCB). The SCB size is defined by scbMemSize.  The SCB is a locked block, and as long
  796. as the session is open, the SCB cannot be modified in any way by the application. 
  797. There is one SCB for each open session.
  798.  
  799. AFPAttnRoutine is a pointer to a routine that is invoked if an attention from the
  800. server is received.  When afpAttnRoutine is equal to zero, no attention routine will
  801. be invoked.
  802.  
  803. CCBStart is the start of the memory to be used by the .XPP driver for the command
  804. control block.  The size of this block is equal to a maximum of 150 bytes.  To determine
  805. the exact requirement refer to the CCB Sizes section later in this chapter.
  806.  
  807. Note:  In the parameter block, the afpSCBPointer and the afpAttnRoutine
  808.        fields overlap with the start of the CCB and are modified by the call.
  809.  
  810. Result codes    aspSizeErr        Command block size is bigger than MaxCmdSize
  811.                 aspBufTooSmall    Reply is bigger than response buffer or
  812.                                   buffer will be filled, data will be truncated
  813.                 aspNoServer       Server not responding
  814.                 aspServerBusy     Server cannot open another session
  815.                 aspBadVersNum     Server cannot support the offered ASP
  816.                                   version number
  817.                 aspNoMoreSess     Driver cannot support another session.
  818.  
  819.  
  820. »AFPWrite Command Format
  821.  
  822. The AFPWrite and AFPRead command formats allow the calling application to make AFP-level
  823. calls that read or write a data block that is larger than a single ASP-level call is
  824. capable of reading or writing.  The maximum number of bytes of data that can be read
  825. or written at the ASP level is equal to quantumSize.
  826.  
  827. FUNCTION AFPCommand (xParamBlock: XPPParmBlkPtr; async: BOOLEAN) : OSErr;
  828.  
  829. Parameter block
  830.   -->    18    cmdResult   long word  AFP command result
  831.   -->    26    csCode      word       Always AFPCall
  832.   -->    28    sessRefnum  word       Session number
  833.   -->    30    aspTimeout  byte       Retry interval in seconds
  834.   -->    32    cbSize      word       Command buffer size
  835.   -->    34    cbPtr       pointer    Command buffer
  836.   <->    38    rbSize      word       Reply buffer size and reply size
  837.   -->    40    rbPtr       pointer    Reply buffer pointer
  838.   -->    44    wdSize      word       (used internally)
  839.   <->    46    wdPtr       pointer    Write data pointer  (updated)
  840.   -->    50    ccbStart    record     Start of memory for CCB
  841.  
  842. CmdResult is four bytes of data returned from the server containing an indication of
  843. the result of the AFP command.
  844.  
  845. SessRefnum is the session reference number returned in the AFPLogin call.
  846.  
  847. ASPTimeOut is the interval in seconds between retries of the call.
  848.  
  849. CBSize is the size in bytes of the block data that contains the command to be sent to
  850. the server on the session.  The size of the command block must not exceed the value
  851. of aspMaxCmdSize returned by the aspGetParms call.
  852.  
  853. CBPtr points to the block of data (see command block structure below) containing the
  854. AFP write command that is to be sent to the server on the session.  The first byte of
  855. the Command Block must contain the AFP write command byte.
  856.  
  857. RBSize is passed and indicates the size of the reply buffer in bytes expected by the
  858. command.  RBSize is also returned and indicates the size of the reply that was actually
  859. returned.
  860.  
  861. RBPtr points to the reply buffer.
  862.  
  863. WDSize is used internally.
  864.  
  865. Note:  This command does not pass the write data size in the queue element
  866.        but in the command buffer.  XPP will look for the size in that buffer.
  867.  
  868. WDPtr is a pointer to the block of data to be written.  Note that this field will be
  869. updated by XPP as it proceeds and will always point to that section of the data which
  870. XPP is currently writing.
  871.  
  872. CCBStart is the start of the memory to be used by the XPP driver for the command
  873. control block.  The size of this block is equal to a maximum of 296 bytes.  To determine
  874. the exact requirement refer to the CCB Sizes section later in this chapter.
  875.  
  876. Command Block Structure:  The AFP write command passes several arguments to XPP in
  877. the command buffer itself. The byte offsets are relative to the location pointed to
  878. by cbPtr.
  879.  
  880.   -->    0    cmdByte       byte       AFP call command byte
  881.   -->    1    startEndFlag  byte       Start/end Flag
  882.   <->    4    rwOffset      long word  Offset within fork to write
  883.   <->    8    reqCount      long word  Requested count
  884.  
  885. CmdByte is the AFP call command byte and must contain the AFP write command code.
  886.  
  887. StartEndFlag is a one-bit flag (the high bit of the byte) indicating whether the
  888. rwOffset field is relative to the beginning or the end of the fork (all other bits
  889. are zero).
  890.  
  891.   0 = relative to the beginning of the fork
  892.   1 = relative to the end of the fork
  893.  
  894. RWOffset is the byte offset within the fork at which the write is to begin.
  895.  
  896. ReqCount indicates the size of the data to be written and is returned as the actual
  897. size written.
  898.  
  899. The rwOffset and reqCount fields are modified by XPP as the write proceeds and will
  900. always indicate the current value of these fields.
  901.  
  902. The Pascal structure of the AFP command buffer follows:
  903.  
  904. AFPCommandBlock = PACKED RECORD
  905.                     cmdByte:       Byte;
  906.                     startEndFlag:  Byte;
  907.                     forkRefNum:    INTEGER;    {used by server}
  908.                     rwOffset:      LONGINT;
  909.                     reqCount:      LONGINT;
  910.                     newLineFlag:   Byte;       {unused by write}
  911.                     newLineChar:   CHAR;       {unused by write}
  912.                   END;
  913.  
  914. Result codes    aspParamErr       Invalid session number
  915.                 aspSizeErr        Command block size is bigger than MaxCmdSize
  916.                 aspSessClosed     Session is closing
  917.                 aspBufTooSmall    Reply is bigger than response buffer
  918.  
  919. »AFPRead Command Format
  920.  
  921. The AFPWrite and AFPRead command formats allow the calling application to make AFP-level
  922. calls that read or write a data block that is larger than a single ASP-level call is
  923. capable of reading or writing.  The maximum number of bytes of data that can be read
  924. or written at the ASP level is equal to quantumSize.
  925.  
  926. FUNCTION AFPCommand (xParamBlock: XPPParmBlkPtr; async: BOOLEAN) : OSErr;
  927.  
  928. Parameter block
  929.   -->    18    cmdResult   long word  ASP command result
  930.   -->    26    csCode      word       Always AFPCall
  931.   -->    28    sessRefnum  word       Session number
  932.   -->    30    aspTimeout  byte       Retry interval in seconds
  933.   -->    32    cbSize      word       Command buffer size
  934.   -->    34    cbPtr       pointer    Command buffer
  935.   -->    38    rbSize      word       Used internally
  936.   <->    40    rbPtr       pointer    Reply buffer pointer (updated)
  937.   -->    50    ccbStart    record     Start of memory for CCB
  938.  
  939. CmdResult is four bytes of data returned from the server containing an indication of
  940. the result of the AFP command.
  941.  
  942. SessRefnum is the session reference number returned in the AFPLogin  call.
  943.  
  944. ASPTimeOut is the interval in seconds between retries of the call.
  945.  
  946. CBSize is the size in bytes of the block data that contains the command to be sent to
  947. the server on the session.  The size of the command block must not exceed the value
  948. of aspMaxCmdSize returned by the GetParms call.
  949.  
  950. CBPtr points to the block of data (command block) containing the AFP read command
  951. that is to be sent to the server on the session.  The first byte of the command block
  952. must contain the AFP read command byte.  The command block structure is shown below.
  953.  
  954. RBSize  is used internally.
  955.  
  956. Note:  This command does not pass the read size in the queue element but
  957.        in the command buffer.  XPP will look for the size in that buffer.
  958.  
  959. RBPtr points to the reply buffer.  Note that this field will be updated by XPP as it
  960. proceeds and will always point to that section of the buffer that XPP is currently
  961. reading into.
  962.  
  963. CCBStart is the start of the memory to be used by the .XPP driver for the command
  964. control block.  The size of this block is equal to a maximum of 150 bytes.  To determine
  965. the exact requirement refer to The CCB Sizes section later in this chapter.
  966.  
  967. Command Block Structure:  The AFP read command passes several arguments to XPP in the
  968. command buffer itself. The byte offsets are relative to the location pointed to by
  969. cbPointer.
  970.  
  971.   -->    0    cmdByte      byte       AFP call command byte
  972.   <->    4    rwOffset     long word  Offset within fork to read
  973.   <->    8    reqCount     long word  Requested count
  974.   -->    12   newLineFlag  byte       Newline Flag
  975.   -->    13   newLineChar  byte       Newline Character
  976.  
  977. CmdByte is the AFP call command byte and must contain the AFP read command code.
  978.  
  979. RWOffset is the byte offset within the fork at which the read is to begin.
  980.  
  981. ReqCount  indicates the size of the read data buffer and is returned as the actual
  982. size read.
  983.  
  984. The rwOffset and reqCount fields are modified by XPP as the read proceeds and will
  985. always indicate the current value of these fields.
  986.  
  987. NewLineFlag is a one-bit flag (the high bit of the byte) indicating whether or not
  988. the read is to terminate at a specified character (all other bits are zero).
  989.  
  990.   0 = no Newline Character is specified
  991.   1 = a Newline Character is specified
  992.  
  993. NewLineChar is any character from $00 to $FF (inclusive) that, when encountered in
  994. reading the fork, causes the read operation to terminate.
  995.  
  996. The Pascal structure of the AFPCommand follows:
  997.  
  998. AFPCommandBlock = PACKED RECORD
  999.                     cmdByte:       Byte;
  1000.                     startEndFlag:  Byte;     {unused for read}
  1001.                     forkRefNum:    INTEGER;  {used by server}
  1002.                     rwOffset:      LONGINT;
  1003.                     reqCount:      LONGINT;
  1004.                     newLineFlag:   Byte;
  1005.                     newLineChar:   CHAR;
  1006.                   END;
  1007.  
  1008. Result codes    aspParamErr       Invalid session number
  1009.                 aspSizeErr        Command block size is bigger than MaxCmdSize
  1010.                 aspSessClosed     Session is closing
  1011.                 aspBufTooSmall    Reply is bigger than response buffer
  1012.  
  1013.         
  1014.  
  1015. æKY AFPCommandBlock
  1016. æFp Appletalk.p
  1017. æT PACKED RECORD
  1018. æC AFPCommandBlock = PACKED RECORD
  1019.    cmdByte: Byte;
  1020.    startEndFlag: Byte;
  1021.    forkRefNum: INTEGER;
  1022.    rwOffset: LONGINT;
  1023.    reqCount: LONGINT;
  1024.    newLineFlag: Byte;
  1025.    newLineChar: CHAR;
  1026.    END;
  1027.  
  1028. æKY afpContLogin
  1029. æFp Appletalk.p
  1030. æC afpContLogin = 19; {AFPCall command codes}
  1031.  
  1032. æKY afpCopyFile
  1033. æFp Appletalk.p
  1034. æC afpCopyFile = 5; {AFPCall command codes}
  1035.  
  1036. æKY afpDelete
  1037. æFp Appletalk.p
  1038. æC afpDelete = 8; {AFPCall command codes}
  1039.  
  1040. æKY afpDirClose
  1041. æFp Appletalk.p
  1042. æC afpDirClose = 3; {AFPCall command codes}
  1043.  
  1044. æKY afpDirCreate
  1045. æFp Appletalk.p
  1046. æC afpDirCreate = 6; {AFPCall command codes}
  1047.  
  1048. æKY afpDTClose
  1049. æFp Appletalk.p
  1050. æC afpDTClose = 49; {AFPCall command codes}
  1051.  
  1052. æKY afpDTOpen
  1053. æFp Appletalk.p
  1054. æC afpDTOpen = 48; {AFPCall command codes}
  1055.  
  1056. æKY afpEnumerate
  1057. æFp Appletalk.p
  1058. æC afpEnumerate = 9; {AFPCall command codes}
  1059.  
  1060. æKY afpFileCreate
  1061. æFp Appletalk.p
  1062. æC afpFileCreate = 7; {AFPCall command codes}
  1063.  
  1064. æKY afpFlush
  1065. æFp Appletalk.p
  1066. æC afpFlush = 10; {AFPCall command codes}
  1067.  
  1068. æKY afpForkClose
  1069. æFp Appletalk.p
  1070. æC afpForkClose = 4; {AFPCall command codes}
  1071.  
  1072. æKY afpForkFlush
  1073. æFp Appletalk.p
  1074. æC afpForkFlush = 11; {AFPCall command codes}
  1075.  
  1076. æKY afpGetAPPL
  1077. æFp Appletalk.p
  1078. æC afpGetAPPL = 55; {AFPCall command codes}
  1079.  
  1080. æKY afpGetCmt
  1081. æFp Appletalk.p
  1082. æC afpGetCmt = 58; {AFPCall command codes}
  1083.  
  1084. æKY afpGetDirParms
  1085. æFp Appletalk.p
  1086. æC afpGetDirParms = 12; {AFPCall command codes}
  1087.  
  1088. æKY afpGetFileParms
  1089. æFp Appletalk.p
  1090. æC afpGetFileParms = 13; {AFPCall command codes}
  1091.  
  1092. æKY afpGetFlDrParms
  1093. æFp Appletalk.p
  1094. æC afpGetFlDrParms = 34; {AFPCall command codes}
  1095.  
  1096. æKY afpGetForkParms
  1097. æFp Appletalk.p
  1098. æC afpGetForkParms = 14; {AFPCall command codes}
  1099.  
  1100. æKY afpGetIcon
  1101. æFp Appletalk.p
  1102. æC afpGetIcon = 51; {AFPCall command codes}
  1103.  
  1104. æKY afpGetSInfo
  1105. æFp Appletalk.p
  1106. æC afpGetSInfo = 15; {AFPCall command codes}
  1107.  
  1108. æKY afpGetSParms
  1109. æFp Appletalk.p
  1110. æC afpGetSParms = 16; {AFPCall command codes}
  1111.  
  1112. æKY afpGetVolParms
  1113. æFp Appletalk.p
  1114. æC afpGetVolParms = 17; {AFPCall command codes}
  1115.  
  1116. æKY afpGtIcnInfo
  1117. æFp Appletalk.p
  1118. æC afpGtIcnInfo = 52; {AFPCall command codes}
  1119.  
  1120. æKY afpLogin
  1121. æFp Appletalk.p
  1122. æC afpLogin = 18; {AFPCall command codes}
  1123.  
  1124. æKY afpLogout
  1125. æFp Appletalk.p
  1126. æC afpLogout = 20; {AFPCall command codes}
  1127.  
  1128. æKY afpMapID
  1129. æFp Appletalk.p
  1130. æC afpMapID = 21; {AFPCall command codes}
  1131.  
  1132. æKY afpMapName
  1133. æFp Appletalk.p
  1134. æC afpMapName = 22; {AFPCall command codes}
  1135.  
  1136. æKY afpMove
  1137. æFp Appletalk.p
  1138. æC afpMove = 23; {AFPCall command codes}
  1139.  
  1140. æKY afpOpenDir
  1141. æFp Appletalk.p
  1142. æC afpOpenDir = 25; {AFPCall command codes}
  1143.  
  1144. æKY afpOpenFork
  1145. æFp Appletalk.p
  1146. æC afpOpenFork = 26; {AFPCall command codes}
  1147.  
  1148. æKY afpOpenVol
  1149. æFp Appletalk.p
  1150. æC afpOpenVol = 24; {AFPCall command codes}
  1151.  
  1152. æKY afpRead
  1153. æFp Appletalk.p
  1154. æC afpRead = 27; {AFPCall command codes}
  1155.  
  1156. æKY afpRename
  1157. æFp Appletalk.p
  1158. æC afpRename = 28; {AFPCall command codes}
  1159.  
  1160. æKY afpRmvAPPL
  1161. æFp Appletalk.p
  1162. æC afpRmvAPPL = 54; {AFPCall command codes}
  1163.  
  1164. æKY afpRmvCmt
  1165. æFp Appletalk.p
  1166. æC afpRmvCmt = 57; {AFPCall command codes}
  1167.  
  1168. æKY afpSetDirParms
  1169. æFp Appletalk.p
  1170. æC afpSetDirParms = 29; {AFPCall command codes}
  1171.  
  1172. æKY afpSetFileParms
  1173. æFp Appletalk.p
  1174. æC afpSetFileParms = 30; {AFPCall command codes}
  1175.  
  1176. æKY afpSetFlDrParms
  1177. æFp Appletalk.p
  1178. æC afpSetFlDrParms = 35; {AFPCall command codes}
  1179.  
  1180. æKY afpSetForkParms
  1181. æFp Appletalk.p
  1182. æC afpSetForkParms = 31; {AFPCall command codes}
  1183.  
  1184. æKY afpSetVolParms
  1185. æFp Appletalk.p
  1186. æC afpSetVolParms = 32; {AFPCall command codes}
  1187.  
  1188. æKY afpVolClose
  1189. æFp Appletalk.p
  1190. æC afpVolClose = 2; {AFPCall command codes}
  1191.  
  1192. æKY afpWrite
  1193. æFp Appletalk.p
  1194. æC afpWrite = 33; {AFPCall command codes}
  1195.  
  1196. æKY ASPAbortOS
  1197. æFp Appletalk.p
  1198. æT FUNCTION
  1199. æD FUNCTION ASPAbortOS(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1200. æDT myVariable := ASPAbortOS(thePBptr,async);
  1201. æRI ASPAbortOS function  V-537
  1202. æC  
  1203. Parameter block
  1204.   -->    26    csCode            word     Always ASPAbortOS
  1205.   -->    28    abortSCBPointer   pointer  Pointer to session control block
  1206.  
  1207. ASPAbortOS aborts a pending (not yet completed) ASPOpenSession call.  The aborted
  1208. ASPOpenSession call will return a reqAborted error.
  1209.  
  1210. AbortSCBPointer points to the original SCB used in the the pending ASPOpenSession
  1211. call.
  1212.  
  1213. Result codes    cbNotFound    SCB not found, no outstanding open session
  1214.                               to be aborted.
  1215.                               Pointer did not point to an open session SCB.
  1216.  
  1217. æKY ASPCloseAll
  1218. æFp Appletalk.p
  1219. æT FUNCTION
  1220. æD FUNCTION ASPCloseAll(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1221. æDT myVariable := ASPCloseAll(thePBptr,async);
  1222. æRI ASPCloseAll function  V-538
  1223. æC  
  1224. Parameter block
  1225.   -->    26    csCode  word  Always ASPCloseAll
  1226.  
  1227. ASPCloseAll closes every session that the driver has active, aborting all active
  1228. requests and invoking the attention routines where provided.  This call should be
  1229. used carefully.  ASPCloseAll can be used as a system level resource for making sure
  1230. all sessions are closed prior to closing the driver.
  1231.  
  1232. æKY ASPCloseSession
  1233. æFp Appletalk.p
  1234. æT FUNCTION
  1235. æD FUNCTION ASPCloseSession(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1236. æDT myVariable := ASPCloseSession(thePBptr,async);
  1237. æRI ASPCloseSession function  V-537
  1238. æC  
  1239. Parameter block
  1240.   -->    26    csCode      word  Always ASPCloseSession
  1241.   -->    28    sessRefnum  word  Session reference number
  1242.  
  1243. ASPCloseSession closes the session identified by the sessRefnum returned in the
  1244. ASPOpenSession call.  ASPCloseSession aborts any calls that are active on the session,
  1245. closes the session, and calls the attention routine, if any, with an attention code
  1246. of zero (zero is invalid as a real attention code).
  1247.  
  1248. Result codes    aspParamErr      Parameter error, indicates an invalid
  1249.                                  session reference number
  1250.                 aspSessClosed    Session already in process of closing
  1251.  
  1252. æKY ASPGetParms
  1253. æFp Appletalk.p
  1254. æT FUNCTION
  1255. æD FUNCTION ASPGetParms(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1256. æDT myVariable := ASPGetParms(thePBptr,async);
  1257. æRI ASPGetParms function  V-538
  1258. æC  
  1259. Parameter block
  1260.   -->    26    csCode          word  Always ASPGetParms
  1261.   -->    28    aspMaxCmdSize   word  Maximum size of command block
  1262.   -->    30    aspQuantumSize  word  Maximum data size
  1263.   -->    32    numSesss        word  Number of sessions
  1264.  
  1265. ASPGetParms returns three ASP parameters.  This call does not require an open session.
  1266.  
  1267. ASPMaxCmdSize is the maximum size of a command that can be sent to the server.
  1268.  
  1269. ASPQuantumSize is the maximum size of data that can be transferred to the server in a
  1270. Write request or from the server in a command reply.
  1271.  
  1272. NumSess is the number of concurrent sessions supported by the driver.
  1273.  
  1274. æKY ASPGetStatus
  1275. æFp Appletalk.p
  1276. æT FUNCTION
  1277. æD FUNCTION ASPGetStatus(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1278. æDT myVariable := ASPGetStatus(thePBptr,async);
  1279. æRI ASPGetStatus function  V-540
  1280. æC  
  1281. Parameter block
  1282.   -->    26    csCode      word       Always ASPGetStatus
  1283.   -->    30    aspTimeout  byte       Retry interval in seconds
  1284.   -->    31    aspRetry    byte       Number of retries
  1285.   -->    32    serverAddr  long word  Server socket address
  1286.   <->    38    rbSize      word       Reply buffer and reply size
  1287.   -->    40    rbPtr       pointer    Reply buffer pointer
  1288.   -->    50    ccbStart    record     Start of memory for CCB
  1289.  
  1290. ASPGetStatus returns server status.  This call is also used as GetServerInfo at the
  1291. AFP level. This call is unique in that it transfers data over the network without
  1292. having a session open.  This call does not pass any data but requests that server
  1293. status be returned.
  1294.  
  1295. ASPTimeOut is the interval in seconds between retries of the call.
  1296.  
  1297. ASPRetry is the number of retries that will be attempted.
  1298.  
  1299. ServerAddr is the network identifier or address of the socket on which the server is
  1300. listening.
  1301.  
  1302. RBSize is passed and indicates the size of the reply buffer in bytes expected by the
  1303. command. RBSize is also returned and indicates the size of the reply that was actually
  1304. returned.
  1305.  
  1306. RBPtr points to the reply buffer.
  1307.  
  1308. CCBStart is the start of the memory to be used by the .XPP driver for the command
  1309. control block.  The size of this block is equal to a maximum of 150 bytes.  To determine
  1310. the exact requirement refer to the CCB Sizes section of this document.
  1311.  
  1312. Result codes    aspBufTooSmall    Reply is bigger than response buffer,
  1313.                                   or Replysize is bigger than ReplyBuffsize
  1314.                 aspNoServer       No response from server at address used
  1315.                                   in call
  1316.  
  1317. æKY ASPOpenSession
  1318. æFp Appletalk.p
  1319. æT FUNCTION
  1320. æD FUNCTION ASPOpenSession(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1321. æDT myVariable := ASPOpenSession(thePBptr,async);
  1322. æRI ASPOpenSession function  V-536
  1323. æC 
  1324. »AppleTalk Session Protocol Functions
  1325.  
  1326. This section contains descriptions of the .XPP driver functions that you can call. 
  1327. Each function description shows the required parameter block fields, their offsets
  1328. within the parameter block and a brief definition of the field.  Possible result
  1329. codes are also described.
  1330.  
  1331. »Note on Result Codes
  1332.  
  1333. An important distinction exists between the aspParamErr and aspSessClose  result
  1334. codes that may be returned by the .XPP driver.
  1335.  
  1336. When the driver returns aspParamErr to a call that takes as an input a session reference
  1337. number, the session reference number does not relate to a valid open session.  There
  1338. could be several reasons for this, such as the workstation or server end closed the
  1339. session or the server end of the session died.
  1340.  
  1341. The aspSessClosed result code indicates that even though the session reference number
  1342. relates to a valid session, that particular session is in the process of closing down
  1343. (although  the session is not yet closed).
  1344.  
  1345. FUNCTION ASPOpenSession (xParamBlock: XPPParmBlkPtr; async: BOOLEAN) : OSErr;
  1346.  
  1347. Parameter block
  1348.   -->    26    csCode       word       Always ASPOpenSess
  1349.   -->    28    sessRefnum   word       Session reference number
  1350.   -->    30    aspTimeout   byte       Retry interval in seconds
  1351.   -->    31    aspRetry     byte       Number of retries
  1352.   -->    32    serverAddr   long word  Server socket address
  1353.   -->    36    scbPointer   pointer    Pointer to session control block
  1354.   -->    40    attnRoutine  pointer    Pointer to attention routine
  1355.  
  1356. ASPOpenSession initiates (opens) a session between the workstation and a server.  The
  1357. required parameter block is shown above.  A brief definition of the fields follows.
  1358.  
  1359. SessRefnum is a unique number identifying the open session between the workstation
  1360. and the server.  The SessRefnum is returned when the function completes successfully
  1361. and is used in all calls to identify the session.
  1362.  
  1363. ASPTimeOut is the interval in seconds between retries of the open session request.
  1364.  
  1365. ASPRetry is the number of retries that will be attempted.
  1366.  
  1367. ServerAddr is the network identifier or address of the socket on which the server is
  1368. listening.
  1369.  
  1370. SCBPointer points to a nonrelocatable block of data for the session control block
  1371. (SCB) that the .XPP driver reserves for use in maintaining an open session.   The SCB
  1372. size is defined by the constant scbMemSize.  The SCB is a locked block and as long as
  1373. the session is open, the SCB cannot be modified in any way by the application.  There
  1374. is one SCB for each open session.  This block can be reused when a CloseSess call is
  1375. issued and completed for that session, or when the session is indicated as closed
  1376. through return of aspParamErr as the result of a call for that session.
  1377.  
  1378. AttnRoutine is a pointer to a routine that is invoked if an attention from the server
  1379. is received, or upon session closing.  If this pointer is equal to zero, no attention
  1380. routine will be invoked.
  1381.  
  1382. Result codes    aspNoMoreSess    Driver cannot support another session
  1383.                 aspParamErr      Server returned bad (positive) error code    
  1384.                 aspNoServers     No servers at that address, or the server
  1385.                                  did not respond to the request
  1386.                 reqAborted       OpenSess was aborted by an AbortOS
  1387.                 aspBadVersNum    Server cannot support the offered 
  1388.                                  version number
  1389.                 aspServerBusy    Server cannot open another session
  1390.  
  1391. Note: The number of sessions that the driver is capable of supporting
  1392.       depends on the machine that the driver is running on. 
  1393.  
  1394. æKY ASPUserCommand
  1395. æFp Appletalk.p
  1396. æT FUNCTION
  1397. æD FUNCTION ASPUserCommand(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1398. æDT myVariable := ASPUserCommand(thePBptr,async);
  1399. æRI ASPUserCommand function  V-539
  1400. æC  
  1401. Parameter block
  1402.   -->    18    cmdResult   long word  ASP command result
  1403.   -->    26    csCode      word       Always ASPUserCommand
  1404.   -->    28    sessRefnum  word       Session number
  1405.   -->    30    aspTimeout  byte       Retry interval in seconds
  1406.   -->    32    cbSize      word       Command block size
  1407.   -->    34    cbPtr       pointer    Command block pointer
  1408.   <->    38    rbSize      word       Reply buffer and reply size
  1409.   -->    40    rbPtr       pointer    Reply buffer pointer
  1410.   -->    50    ccbStart    record     Start of memory for CCB
  1411.  
  1412. ASPUserCommand is used to send a command to the server on a session.
  1413.  
  1414. SessRefnum is the session reference number returned in the ASPOpenSession call.
  1415.  
  1416. ASPTimeOut is the interval in seconds between retries of the call.  Notice that there
  1417. is no aspRetry field (retries are infinite).  The command will be retried at the
  1418. prescribed interval until completion or the session is closed.
  1419.  
  1420. CBSize is the size in bytes of the block of data that contains the command to be sent
  1421. to the server on the session.  The size of the command block must not exceed the
  1422. value of aspMaxCmdSize returned by the ASPGetParms call.
  1423.  
  1424. CBPointer points to the block of data containing the command that is to be sent to
  1425. the server on the session.
  1426.  
  1427. RBSize is passed and indicates the size of the reply buffer in bytes expected by the
  1428. command.  RBSize is also returned and indicates the size of the reply that was actually
  1429. returned.
  1430.  
  1431. RBPtr points to the reply buffer.
  1432.  
  1433. CCBStart is the start of the memory to be used by the .XPP driver for the command
  1434. control block.  The size of this block is equal to a maximum of 150 bytes.  To determine
  1435. the exact requirement refer to the CCB Sizes section of this document.
  1436.  
  1437. Result codes     aspParamErr       Invalid session number, session has
  1438.                                    been closed
  1439.                  aspSizeErr        Command block size is bigger than MaxCmdSize
  1440.                  aspSessClosed     Session is closing
  1441.                  aspBufTooSmall    Reply is bigger than response buffer;
  1442.                                    the buffer will be filled, data will
  1443.                                    be truncated
  1444.  
  1445. æKY ASPUserWrite
  1446. æFp Appletalk.p
  1447. æT FUNCTION
  1448. æD FUNCTION ASPUserWrite(thePBptr: XPPParmBlkPtr;async: BOOLEAN): OSErr;
  1449. æDT myVariable := ASPUserWrite(thePBptr,async);
  1450. æRI ASPUserWrite function  V-538
  1451. æC  
  1452. Parameter block
  1453.   -->    18    cmdResult   long word  ASP command result
  1454.   -->    26    csCode      word       Always UserWrite
  1455.   -->    28    sessRefnum  word       Session reference number
  1456.   -->    30    aspTimeout  byte       Retry interval in seconds
  1457.   -->    32    cbSize      word       Command block size
  1458.   -->    34    cbPtr       pointer    Command block pointer
  1459.   <->    38    rbSize      word       Reply buffer size and reply size
  1460.   -->    40    rbPtr       pointer    Reply buffer pointer
  1461.   <->    44    wdSize      word       Write data size
  1462.   -->    46    wdPtr       pointer    Write data pointer
  1463.   -->    50    ccbStart    record     Start of memory for CCB
  1464.  
  1465. ASPUserWrite transfers data on a session.  ASPUserWrite is one of the two main calls
  1466. that can be used to transfer data on an ASP session.  The other call that performs a
  1467. similar data transfer  is ASPUserCommand described below.  The ASPUserWrite command
  1468. returns data in two different places.  Four bytes of data are returned in the cmdResult
  1469. field and a variable size reply buffer is also returned.
  1470.  
  1471. CmdResult is four bytes of data returned by the server.
  1472.  
  1473. SessRefnum is the session reference number returned in the ASPOpenSession call.
  1474.  
  1475. ASPTimeOut is the interval in seconds between retries of the call.  Notice that there
  1476. is no aspRetry field (retries are infinite).  The command will be retried at the
  1477. prescribed interval until completion or the session is closed.
  1478.  
  1479. CBSize is the size in bytes of the command data that is to be written on the session.
  1480.  The size of the command block must not exceed the value of aspMaxCmdSize returned by
  1481. the ASPGetParms call. Note that this buffer is not the data to be written by the
  1482. command but only the data of the command itself.
  1483.  
  1484. CBPtr points to the command data.
  1485.  
  1486. RBSize is passed and indicates the size of the reply buffer in bytes expected by the
  1487. command.  RBSize is also returned and indicates the size of the reply that was actually
  1488. returned.
  1489.  
  1490. RBPtr points to the reply buffer.
  1491.  
  1492. WDSize is passed and indicates the size of the write data in bytes to be sent by the
  1493. command.  WDSize is also returned and indicates the size of the write data that was
  1494. actually written.
  1495.  
  1496. WDPointer points to the write data buffer.
  1497.  
  1498. CCBStart is the start of the memory to be used by the .XPP driver for the command
  1499. control block.  The size of this block is equal to a maximum of 296 bytes.  To determine
  1500. the exact requirement, refer to the CCB Sizes section of this document.
  1501.  
  1502. Result codes     aspParamErr       Invalid session number, session has
  1503.                                    been closed
  1504.                  aspSizeErr        Command block size is bigger than MaxCmdSize
  1505.                  aspSessClosed     Session is closing
  1506.                  aspBufTooSmall    Reply is bigger than response buffer;
  1507.                                    the buffer will be filled, data will
  1508.                                    be truncated
  1509.  
  1510. æKY ATPaddrBlock
  1511. æFp Appletalk.p
  1512. æC ATPaddrBlock = ATP.addrBlock;
  1513.  
  1514. æKY ATPAddRsp
  1515. æFp Appletalk.p
  1516. æT FUNCTION
  1517. æD FUNCTION ATPAddRsp(abRecord: ABRecHandle): OSErr;
  1518. æDT myVariable := ATPAddRsp(abRecord);
  1519. æMM   
  1520. æRI ATPAddRsp function II-295
  1521. æC  
  1522. ABusRecord
  1523.   <--    abOpcode         {always tATPAddRsp}
  1524.   <--    abResult         {result code}
  1525.   -->    abUserReference  {for your use}
  1526.   -->    atpSocket        {responding socket number}
  1527.   -->    atpAddress       {destination socket address}
  1528.   -->    atpReqCount      {buffer size in bytes}
  1529.   -->    atpDataPtr       {pointer to buffer}
  1530.   -->    atpTransID       {transaction ID}
  1531.   -->    atpUserData      {user bytes}
  1532.   -->    atpEOM           {end-of-message flag}
  1533.   -->    atpNumRsp        {sequence number}
  1534.  
  1535. ATPAddRsp sends one additional response packet to a socket that has already been sent
  1536. the initial part of a response via ATPSndRsp. ATPSocket contains the socket number
  1537. from which the response should be sent and atpAddress contains the internet address
  1538. of the socket to which the response should be sent. ATPTransID must contain the
  1539. transaction ID. ATPDataPtr and atpReqCount specify the location and size of a buffer
  1540. that contains the information to send; atpNumRsp is the sequence number of the response.
  1541. ATPEOM is TRUE if this response datagram is the final packet in a transaction composed
  1542. of a group of packets. ATPUserData contains the user bytes to be sent in this response
  1543. datagram’s ATP header.
  1544.  
  1545. Note:  No BDS is needed with ATPAddRsp because all pertinent information
  1546.        is passed within the record.
  1547.  
  1548. Result codes    noErr         No error
  1549.                 badATPSkt     Bad responding socket
  1550.                 badBuffNum    Bad sequence number
  1551.                 noSendResp    ATPAddRsp issued before ATPSndRsp
  1552.                 noDataArea    Too many outstanding ATP calls
  1553.  
  1554. æKY ATPaKillQEl
  1555. æFp Appletalk.p
  1556. æC ATPaKillQEl = KILL.aKillQEl;
  1557.  
  1558. æKY ATPatpFlags
  1559. æFp Appletalk.p
  1560. æC ATPatpFlags = ATP.atpFlags;
  1561.  
  1562. æKY ATPatpSocket
  1563. æFp Appletalk.p
  1564. æC ATPatpSocket = ATP.atpSocket;
  1565.  
  1566. æKY ATPbdsPointer
  1567. æFp Appletalk.p
  1568. æC ATPbdsPointer = ATP.bdsPointer;
  1569.  
  1570. æKY ATPbdsSize
  1571. æFp Appletalk.p
  1572. æC ATPbdsSize = OTH2.bdsSize;
  1573.  
  1574. æKY ATPbitMap
  1575. æFp Appletalk.p
  1576. æC ATPbitMap = OTH1.u0.bitMap;
  1577.  
  1578. æKY ATPCloseSocket
  1579. æFp Appletalk.p
  1580. æT FUNCTION
  1581. æD FUNCTION ATPCloseSocket(atpSocket: Byte): OSErr;
  1582. æDT myVariable := ATPCloseSocket(atpSocket);
  1583. æMM   
  1584. æRI ATPCloseSocket function II-291
  1585. æC 
  1586. ATPCloseSocket closes the responding socket whose number is specified by atpSocket.
  1587. It releases the data structures associated with all pending, asynchronous calls
  1588. involving that socket; these pending calls are completed immediately and return the
  1589. result code sktClosed.
  1590.  
  1591. Result codes    noErr         No error
  1592.                 noDataArea    Too many outstanding ATP calls
  1593.  
  1594. æKY ATPcsCode
  1595. æFp Appletalk.p
  1596. æC ATPcsCode = ATP.csCode;
  1597.  
  1598. æKY atpEOMvalue
  1599. æFp Appletalk.p
  1600. æC atpEOMvalue = 16; {ATP End-Of-Message bit }
  1601.  
  1602. æKY ATPGetRequest
  1603. æFp Appletalk.p
  1604. æT FUNCTION
  1605. æD FUNCTION ATPGetRequest(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  1606. æDT myVariable := ATPGetRequest(abRecord,async);
  1607. æMM 
  1608. æRT 20
  1609. æRI ATPGetRequest function II-293, N20-2
  1610. æC  
  1611. ABusRecord
  1612.   <--    abOpcode         {always tATPGetRequest}
  1613.   <--    abResult         {result code}
  1614.   -->    abUserReference  {for your use}
  1615.   -->    atpSocket        {listening socket number}
  1616.   <--    atpAddress       {source socket address}
  1617.   -->    atpReqCount      {buffer size in bytes}
  1618.   -->    atpDataPtr       {pointer to buffer}
  1619.   <--    atpBitMap        {transaction bit map}
  1620.   <--    atpTransID       {transaction ID}
  1621.   <--    atpActCount      {number of bytes actually received}
  1622.   <--    atpUserData      {user bytes}
  1623.   <--    atpXO            {exactly-once flag}
  1624.  
  1625. ATPGetRequest sets up the mechanism to receive a request sent by either an ATPSndRequest
  1626. or an ATPRequest call. ATPSocket contains the socket number of the socket that should
  1627. listen for a request; this socket must already have been opened by calling ATPOpenSocket.
  1628. The address of the socket from which the request was sent is returned in atpAddress.
  1629. ATPDataPtr specifies a buffer to store the incoming request; atpReqCount indicates
  1630. the size of the buffer in bytes. The number of bytes actually received in the request
  1631. is returned in atpActCount. ATPUserData contains the user bytes from the ATP header.
  1632. The transaction bit map is returned in atpBitMap. The transaction ID is returned in
  1633. atpTransID. ATPXO will be TRUE if the request is part of an exactly-once transaction.
  1634.  
  1635. ATPGetRequest completes when a request is received. To cancel an asynchronous ATPGetRequest
  1636. call, you must call ATPCloseSocket, but this cancels all pending calls involving that
  1637. socket.
  1638.  
  1639. Result codes    noErr        No error
  1640.                 badATPSkt    Bad responding socket
  1641.                 sktClosed    Socket closed by a cancel call
  1642.  
  1643. æKY ATPioCompletion
  1644. æFp Appletalk.p
  1645. æC ATPioCompletion = ATP.ioCompletion;
  1646.  
  1647. æKY ATPioRefNum
  1648. æFp Appletalk.p
  1649. æC ATPioRefNum = ATP.ioRefNum;
  1650.  
  1651. æKY ATPioResult
  1652. æFp Appletalk.p
  1653. æC ATPioResult = ATP.ioResult;
  1654.  
  1655. æKY ATPLoad
  1656. æFp Appletalk.p
  1657. æT FUNCTION
  1658. æD FUNCTION ATPLoad: OSErr;
  1659. æDT myVariable := ATPLoad;
  1660. æMM 
  1661. æRT 20, 224
  1662. æRI ATPLoad function II-290, N20-2
  1663. æC 
  1664. •••Refer to Technical Note #224:•••
  1665.  
  1666. ATPLoad first verifies that the .MPP driver is loaded and running. If it isn’t,
  1667. ATPLoad verifies that port B is configured for AppleTalk and isn’t in use, and then
  1668. loads MPP into the system heap.
  1669.  
  1670. ATPLoad then loads the .ATP driver, unless it’s already in memory. On a Macintosh
  1671. 128K, ATPLoad reads the .ATP driver from the system resource file into the application
  1672. heap; on a Macintosh 512K or XL, ATP is read into the system heap.
  1673.  
  1674. Note:  On a Macintosh 512K or XL, ATPLoad and MPPOpen perform essentially
  1675.        the same function.
  1676.  
  1677. Result codes    noErr        No error
  1678.                 portInUse    Port B is already in use
  1679.                 portNotCf    Port B not configured for AppleTalk
  1680.  
  1681. æKY ATPnumOfBuffs
  1682. æFp Appletalk.p
  1683. æC ATPnumOfBuffs = OTH1.u0.numOfBuffs;
  1684.  
  1685. æKY ATPnumOfResps
  1686. æFp Appletalk.p
  1687. æC ATPnumOfResps = SREQ.numOfResps;
  1688.  
  1689. æKY ATPOpenSocket
  1690. æFp Appletalk.p
  1691. æT FUNCTION
  1692. æD FUNCTION ATPOpenSocket(addrRcvd: AddrBlock;VAR atpSocket: Byte): OSErr;
  1693. æDT myVariable := ATPOpenSocket(addrRcvd,atpSocket);
  1694. æMM   
  1695. æRI ATPOpenSocket function II-290
  1696. æC 
  1697. ATPOpenSocket opens a socket for the purpose of receiving requests. ATPSocket contains
  1698. the socket number of the socket to open; if it’s 0, a number is dynamically assigned
  1699. and returned in atpSocket. AddrRcvd contains a filter of the sockets from which
  1700. requests will be accepted. A 0 in the network number, node ID, or socket number field
  1701. of the addrRcvd record acts as a “wild card”; for instance, a 0 in the socket number
  1702. field means that requests will be accepted from all sockets in the node(s) specified
  1703. by the network and node fields.
  1704.  
  1705. Result codes    noErr          No error
  1706.                 tooManySkts    Socket table full
  1707.                 noDataArea     Too many outstanding ATP calls
  1708.  
  1709. Note:  If you’re only going to send requests and receive responses to
  1710.        these requests, you don’t need to open an ATP socket. When you
  1711.        make the ATPSndRequest or ATPRequest call, ATP automatically
  1712.        opens a dynamically assigned socket for that purpose.
  1713.  
  1714. æKY ATPReqCancel
  1715. æFp Appletalk.p
  1716. æT FUNCTION
  1717. æD FUNCTION ATPReqCancel(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  1718. æDT myVariable := ATPReqCancel(abRecord,async);
  1719. æMM   
  1720. æRI ATPReqCancel function II-293
  1721. æC 
  1722. Given the handle to the ABusRecord of a previously made ATPSndRequest or ATPRequest
  1723. call, ATPReqCancel dequeues the ATPSndRequest or ATPRequest call, provided that the
  1724. call hasn’t already completed. ATPReqCancel returns noErr if the ATPSndRequest or
  1725. ATPRequest call is successfully removed from the queue. If it returns cbNotFound,
  1726. check the abResult field of abRecord to verify that the ATPSndRequest or ATPRequest
  1727. call has completed and determine its outcome.
  1728.  
  1729. Result codes    noErr         No error
  1730.                 cbNotFound    ATP control block not found
  1731.  
  1732. æKY ATPreqLength
  1733. æFp Appletalk.p
  1734. æC ATPreqLength = ATP.reqLength;
  1735.  
  1736. æKY ATPreqPointer
  1737. æFp Appletalk.p
  1738. æC ATPreqPointer = ATP.reqPointer;
  1739.  
  1740. æKY ATPreqTID
  1741. æFp Appletalk.p
  1742. æC ATPreqTID = ATP.reqTID;
  1743.  
  1744. æKY ATPRequest
  1745. æFp Appletalk.p
  1746. æT FUNCTION
  1747. æD FUNCTION ATPRequest(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  1748. æDT myVariable := ATPRequest(abRecord,async);
  1749. æMM   
  1750. æRI ATPRequest function II-292
  1751. æC 
  1752. ABusRecord
  1753.   <--    abOpcode         {always tATPRequest}
  1754.   <--    abResult         {result code}
  1755.   -->    abUserReference  {for your use}
  1756.   -->    atpAddress       {destination socket address}
  1757.   -->    atpReqCount      {request size in bytes}
  1758.   -->    atpDataPtr       {pointer to buffer}
  1759.   <--    atpActCount      {number of bytes actually received}
  1760.   -->    atpUserData      {user bytes}
  1761.   -->    atpXO            {exactly-once flag}
  1762.   <--    atpEOM           {end-of-message flag}
  1763.   -->    atpTimeOut       {retry timeout interval in seconds}
  1764.   -->    atpRetries       {maximum number of retries}
  1765.   <--    atpRspUData      {user bytes received in transaction response}
  1766.   -->    atpRspBuf        {pointer to response message buffer}
  1767.   -->    atpRspSize       {size of response message buffer}
  1768.  
  1769. ATPRequest is functionally analogous to ATPSndRequest. It sends a request to another
  1770. socket, but doesn’t require the caller to set up and use the BDS data structure to
  1771. describe the response buffers. ATPAddress indicates the socket to which the request
  1772. should be sent. ATPDataPtr and atpReqCount specify the location and size of a buffer
  1773. that contains the request information to be sent. ATPUserData contains the user bytes
  1774. to be sent in the request’s ATP header. ATPTimeOut indicates the length of time that
  1775. ATPRequest should wait for a response before retransmitting the request. ATPRetries
  1776. indicates the maximum number of retries ATPRequest should attempt.
  1777.  
  1778. To use this call, you must have an area of contiguous buffer space that’s large
  1779. enough to receive all expected datagrams. The various datagrams will be assembled in
  1780. this buffer and returned to you as a complete message upon completion of the transaction.
  1781. The location and size of this buffer are passed in atpRspBuf and atpRspSize. Upon
  1782. completion of the call, the size of the received response message is returned in
  1783. atpActCount. The user bytes received in the ATP header of the first response packet
  1784. are returned in atpRspUData. ATPXO should be TRUE if you want the request to be part
  1785. of an exactly-once transaction.
  1786.  
  1787. Although you don’t provide a BDS, ATPRequest in fact creates one and calls the
  1788. .ATP driver (as in an ATPSndRequest call). For this reason, the abRecord fields
  1789. atpRspBDSPtr and atpNumBufs are used by ATPRequest; you should not expect these
  1790. fields to remain unaltered during or after the function’s execution.
  1791.  
  1792. For ATPRequest to receive and correctly deliver the response as a single message, the
  1793. responding end must, upon receiving the request (with an ATPGetRequest call), generate
  1794. the complete response as a message in a single buffer and then call ATPResponse.
  1795.  
  1796. Note:  The responding end could also use ATPSndRsp and ATPAddRsp provided
  1797.        that each response packet (except the last one) contains exactly 578
  1798.        ATP data bytes; the last packet in the response can contain less than
  1799.        578 ATP data bytes. Also, if this method is used, only the ATP user
  1800.        bytes of the first response packet will be delivered to the requester;
  1801.        any information in the user bytes of the remaining response packets
  1802.        will not be delivered.
  1803.  
  1804. ATPRequest completes when either the transaction is completed or the retry count is
  1805. exceeded.
  1806.  
  1807. Result codes    noErr          No error
  1808.                 reqFailed      Retry count exceeded
  1809.                 tooManyReqs    Too many concurrent requests
  1810.                 sktClosed      Socket closed by a cancel call
  1811.                 noDataArea     Too many outstanding ATP calls
  1812.  
  1813. æKY ATPResponse
  1814. æFp Appletalk.p
  1815. æT FUNCTION
  1816. æD FUNCTION ATPResponse(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  1817. æDT myVariable := ATPResponse(abRecord,async);
  1818. æMM 
  1819. æRT 20
  1820. æRI ATPResponse function II-296, N20-2
  1821. æC 
  1822. ABusRecord
  1823.   <--    abOpcode         {always tATPResponse}
  1824.   <--    abResult         {result code}
  1825.   -->    abUserReference  {for your use}
  1826.   -->    atpSocket        {responding socket number}
  1827.   -->    atpAddress       {destination socket address}
  1828.   -->    atpTransID       {transaction ID)
  1829.   -->    atpRspUData      {user bytes sent in transaction response}
  1830.   -->    atpRspBuf        {pointer to response message buffer}
  1831.   -->    atpRspSize       {size of response message buffer}
  1832.  
  1833. ATPResponse is functionally analogous to ATPSndRsp. It sends a response to another
  1834. socket, but doesn’t require the caller to provide a BDS. ATPAddress must contain the
  1835. complete network address of the socket to which the response should be sent (taken
  1836. from the data provided by an ATPGetRequest call). ATPTransID must contain the transaction
  1837. ID. ATPSocket indicates the socket from which the response should be sent (the socket
  1838. on which the corresponding ATPGetRequest was issued). ATPRspBuf points to the buffer
  1839. containing the response message; the size of this buffer must be passed in atpRspSize.
  1840. The four user bytes to be sent in the ATP header of the first response packet are
  1841. passed in atpRspUData. The last packet of the transaction response is sent with the
  1842. EOM flag set.
  1843.  
  1844. Although you don’t provide a BDS, ATPResponse in fact creates one and calls the .ATP
  1845. driver (as in an ATPSndRsp call). For this reason, the abRecord fields atpRspBDSPtr
  1846. and atpNumBufs are used by ATPResponse; you should not expect these fields to remain
  1847. unaltered during or after the function’s execution.
  1848.  
  1849. During exactly-once transactions ATPResponse won’t complete until the release packet
  1850. is received or the release timer expires.
  1851.  
  1852. Warning:  The maximum permissible size of the response message is 4624 bytes.
  1853.  
  1854. Result codes    noErr         No error
  1855.                 badATPSkt     Bad responding socket
  1856.                 noRelErr      No release received
  1857.                 atpLenErr     Response too big
  1858.                 sktClosed     Socket closed by a cancel call
  1859.                 noDataArea    Too many outstanding ATP calls
  1860.  
  1861. æKY ATPretryCount
  1862. æFp Appletalk.p
  1863. æC ATPretryCount = SREQ.retryCount;
  1864.  
  1865. æKY ATPRspCancel
  1866. æFp Appletalk.p
  1867. æT FUNCTION
  1868. æD FUNCTION ATPRspCancel(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  1869. æDT myVariable := ATPRspCancel(abRecord,async);
  1870. æMM   
  1871. æRI ATPRspCancel function II-296
  1872. æC 
  1873. Given the handle to the ABusRecord of a previously made ATPSndRsp or ATPResponse
  1874. call, ATPRspCancel dequeues the ATPSndRsp or ATPResponse call, provided that the call
  1875. hasn’t already completed. ATPRspCancel returns noErr if the ATPSndRsp or ATPResponse
  1876. call is successfully removed from the queue. If it returns cbNotFound, check the
  1877. abResult field of abRecord to verify that the ATPSndRsp or ATPResponse call has
  1878. completed and determine its outcome.
  1879.  
  1880. Result codes    noErr         No error
  1881.                 cbNotFound    ATP control block not found
  1882.  
  1883. »Example
  1884.  
  1885. This example shows the requesting side of an ATP transaction that asks for a 512-byte
  1886. disk block from the responding end. The block number of the file is a byte and is
  1887. contained in myBuffer[0].
  1888.  
  1889. VAR
  1890.   myABRecord: ABRecHandle;
  1891.   myBDSPtr: BDSPtr;
  1892.   myBuffer: PACKED ARRAY [0..511] OF CHAR;
  1893.   errCode: INTEGER;
  1894.   async: BOOLEAN;
  1895.  
  1896. BEGIN
  1897.   errCode := ATPLoad;
  1898.   IF errCode <> noErr THEN
  1899.     WRITELN('Error in opening AppleTalk')
  1900.     {Maybe serial port B isn't available for use by AppleTalk}
  1901.   ELSE
  1902.     BEGIN
  1903.       {Prepare the BDS; allocate space for a one-element BDS}
  1904.       myBDSPtr := BDSPtr(NewPtr(SIZEOF(BDSElement)));
  1905.       WITH myBDSPtr^[0] DO
  1906.         BEGIN
  1907.           buffSize := 512; {size of our buffer used in reception}
  1908.           buffPtr := @myBuffer; {pointer to the buffer}
  1909.         END;
  1910.       {Prepare the ABusRecord}
  1911.       myBuffer[0] := CHR(1); {requesting disk block number 1}
  1912.       myABRecord := ABRecHandle(NewHandle(atpSize));
  1913.       WITH myABRecord^^ DO
  1914.         BEGIN
  1915.           atpAddress.aNet := 0;
  1916.           atpAddress.aNode := 30; {we probably got this from an NBP call}
  1917.           atpAddress.aSocket := 15; {socket to send request to}
  1918.           atpReqCount := 1; {size of request data field (disk block #)}
  1919.           atpDataPtr := @myBuffer; {ptr to request to be sent}
  1920.           atpRspBDSPtr := @myBDSPtr;
  1921.           atpUserData := 0; {for your use}
  1922.           atpXO := FALSE; {at-least-once service}
  1923.           atpTimeOut := 5; {5-second timeout}
  1924.           atpRetries := 3; {3 retries; request will be sent 4 times max}
  1925.           atpNumBufs := 1; {we're only expecting 1 block to be returned}
  1926.         END;
  1927.       async := FALSE;
  1928.       {Send the request and wait for the response}
  1929.       errCode := ATPSndRequest(myABRecord, async);
  1930.       IF errCode <> noErr THEN
  1931.         WRITELN('An error occurred in the ATPSndRequest call')
  1932.       ELSE
  1933.         BEGIN
  1934.           {The disk block requested is now in myBuffer. We can verify }
  1935.           { that atpNumRsp contains 1, meaning one response received.}
  1936.         . . .
  1937.         END;
  1938.     END;
  1939. END.
  1940.  
  1941. æKY ATPrspNum
  1942. æFp Appletalk.p
  1943. æC ATPrspNum = OTH1.u0.rspNum;
  1944.  
  1945. æKY atpSendChkvalue
  1946. æFp Appletalk.p
  1947. æC atpSendChkvalue = 1; {ATP send checksum bit }
  1948.  
  1949. æKY ATPSndRequest
  1950. æFp Appletalk.p
  1951. æT FUNCTION
  1952. æD FUNCTION ATPSndRequest(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  1953. æDT myVariable := ATPSndRequest(abRecord,async);
  1954. æMM   
  1955. æRI ATPSndRequest function II-291
  1956. æC 
  1957. ABusRecord
  1958.   <--    abOpcode         {always tATPSndRequest}
  1959.   <--    abResult         {result code}
  1960.   -->    abUserReference  {for your use}
  1961.   -->    atpAddress       {destination socket address}
  1962.   -->    atpReqCount      {request size in bytes}
  1963.   -->    atpDataPtr       {pointer to buffer}
  1964.   -->    atpRspBDSPtr     {pointer to response BDS}
  1965.   -->    atpUserData      {user bytes}
  1966.   -->    atpXO            {exactly-once flag}
  1967.   <--    atpEOM           {end-of-message flag}
  1968.   -->    atpTimeOut       {retry timeout interval in seconds}
  1969.   -->    atpRetries       {maximum number of retries}
  1970.   -->    atpNumBufs       {number of elements in response BDS}
  1971.   <--    atpNumRsp        {number of response packets actually received}
  1972.  
  1973. ATPSndRequest sends a request to another socket. ATPAddress is the internet address
  1974. of the socket to which the request should be sent. ATPDataPtr and atpReqCount specify
  1975. the location and size of a buffer that contains the request information to be sent.
  1976. ATPUserData contains the user bytes for the ATP header.
  1977.  
  1978. ATPSndRequest requires you to allocate a response BDS. ATPRspBDSPtr is a pointer to
  1979. the response BDS; atpNumBufs indicates the number of elements in the BDS (this is
  1980. also the maximum number of response datagrams that will be accepted). The number of
  1981. response datagrams actually received is returned in atpNumRsp; if a nonzero value is
  1982. returned, you can examine the response BDS to determine which packets of the transaction
  1983. were actually received. If the number returned is less than requested, one of the
  1984. following is true:
  1985.  
  1986.   •  Some of the packets have been lost and the retry count has been exceeded.
  1987.   •  ATPEOM is TRUE; this means that the response consisted of fewer packets
  1988.      than were expected, but that all packets sent were received (the last
  1989.      packet came with the atpEOM flag set).
  1990.  
  1991. ATPTimeOut indicates the length of time that ATPSndRequest should wait for a response
  1992. before retransmitting the request. ATPRetries indicates the maximum number of retries
  1993. ATPSndRequest should attempt. ATPXO should be TRUE if you want the request to be part
  1994. of an exactly-once transaction.
  1995.  
  1996. ATPSndRequest completes when either the transaction is completed or the retry count
  1997. is exceeded.
  1998.  
  1999. Result codes    noErr          No error
  2000.                 reqFailed      Retry count exceeded
  2001.                 tooManyReqs    Too many concurrent requests
  2002.                 noDataArea     Too many outstanding ATP calls
  2003.  
  2004. æKY ATPSndRsp
  2005. æFp Appletalk.p
  2006. æT FUNCTION
  2007. æD FUNCTION ATPSndRsp(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  2008. æDT myVariable := ATPSndRsp(abRecord,async);
  2009. æMM   
  2010. æRI ATPSndRsp function II-294
  2011. æC  
  2012. ABusRecord
  2013.   <--    abOpcode         {always tATPSdRsp}
  2014.   <--    abResult         {result code}
  2015.   -->    abUserReference  {for your use}
  2016.   -->    atpSocket        {responding socket number}
  2017.   -->    atpAddress       {destination socket address}
  2018.   -->    atpRspBDSPtr     {pointer to response BDS}
  2019.   -->    atpTransID       {transaction ID}
  2020.   -->    atpEOM           {end-of-message flag}
  2021.   -->    atpNumBufs       {number of response packets being sent}
  2022.   -->    atpBDSSize       {number of elements in response BDS}
  2023.  
  2024. ATPSndRsp sends a response to another socket. ATPSocket contains the socket number
  2025. from which the response should be sent and atpAddress contains the internet address
  2026. of the socket to which the response should be sent. ATPTransID must contain the
  2027. transaction ID. ATPEOM is TRUE if the response BDS contains the final packet in a
  2028. transaction composed of a group of packets and the number of packets in the response
  2029. is less than expected. ATPRspBDSPtr points to the buffer data structure containing
  2030. the responses to be sent. ATPBDSSize indicates the number of elements in the response
  2031. BDS, and must be in the range 1 to 8. ATPNumBufs indicates the number of response
  2032. packets being sent with this call, and must be in the range 0 to 8.
  2033.  
  2034. Note:  In some situations, you may want to send only part (or possibly none)
  2035.        of your response message back immediately. For instance, you might be
  2036.        requested to send back seven disk blocks, but have only enough internal
  2037.        memory to store one block. In this case, set atpBDSSize to 7 (total
  2038.        number of response packets), atpNumBufs to 0 (number of response
  2039.        packets currently being sent), and call ATPSndRsp. Then as you read
  2040.        in one block at a time, call ATPAddRsp until all seven response
  2041.        datagrams have been sent.
  2042.  
  2043. During exactly-once transactions, ATPSndRsp won’t complete until the release packet
  2044. is received or the release timer expires.
  2045.  
  2046. Result codes    noErr         No error
  2047.                 badATPSkt     Bad responding socket
  2048.                 noRelErr      No release received
  2049.                 sktClosed     Socket closed by a cancel call
  2050.                 noDataArea    Too many outstanding ATP calls
  2051.                 badBuffNum    Bad sequence number
  2052.  
  2053. æKY atpSTSvalue
  2054. æFp Appletalk.p
  2055. æC atpSTSvalue = 8; {ATP Send-Transmission-Status bit }
  2056.  
  2057. æKY atpTIDValidvalue
  2058. æFp Appletalk.p
  2059. æC atpTIDValidvalue = 2; {ATP trans. ID valid bit }
  2060.  
  2061. æKY ATPtimeOutVal
  2062. æFp Appletalk.p
  2063. æC ATPtimeOutVal = SREQ.timeOutVal;
  2064.  
  2065. æKY ATPtransID
  2066. æFp Appletalk.p
  2067. æC ATPtransID = OTH2.transID;
  2068.  
  2069. æKY ATPUnload
  2070. æFp Appletalk.p
  2071. æT FUNCTION
  2072. æD FUNCTION ATPUnload: OSErr;
  2073. æDT myVariable := ATPUnload;
  2074. æRI ATPUnload function II-290
  2075. æC 
  2076. ATPUnload makes the .ATP driver purgeable; the space isn’t actually released by the
  2077. Memory Manager until necessary.
  2078.  
  2079. Note:  This call applies only to a Macintosh 128K; on a Macintosh 512K
  2080.        or Macintosh XL, ATPUnload has no effect.
  2081.  
  2082. Result codes    noErr    No error
  2083.  
  2084. æKY ATPuserData
  2085. æFp Appletalk.p
  2086. æC ATPuserData = ATP.userData;
  2087.  
  2088. æKY atpXOvalue
  2089. æFp Appletalk.p
  2090. æC atpXOvalue = 32; {ATP exactly-once bit }
  2091.  
  2092. æKY BDSElement,BDSType,BDSPtr
  2093. æFp AppleTalk.p
  2094. æT RECORD
  2095. æC BDSPtr = ^BDSType;
  2096. BDSType = ARRAY [0..7] OF BDSElement;
  2097. BDSElement = RECORD
  2098.    buffSize: INTEGER;
  2099.    buffPtr: Ptr;
  2100.    dataSize: INTEGER;
  2101.    userBytes: LONGINT;
  2102.    END;
  2103.  
  2104. æKY BitMapType
  2105. æFp AppleTalk.p
  2106. æT TYPE
  2107. æC BitMapType = PACKED ARRAY [0..7] OF BOOLEAN;
  2108.  
  2109. æKY BuildBDS
  2110. æFp Appletalk.p
  2111. æT FUNCTION
  2112. æD FUNCTION BuildBDS(buffPtr: Ptr;bdsPtr: Ptr;buffSize: INTEGER): INTEGER;
  2113. æDT myVariable := BuildBDS(buffPtr,bdsPtr,buffSize);
  2114. æRI BuildBDS function  V-515
  2115. æC 
  2116. This routine builds a BDS, for use with the ATP calls.  Given a data buffer of length
  2117. buffSize pointed to by buffPtr, it fills in the BDS pointed to by bdsPtr.  The buffer
  2118. will be broken up into pieces of maximum size (578 bytes).  The user bytes in the BDS
  2119. are not modified by this routine.  This routine is provided only as a convenience;
  2120. generally the caller will be able to build the BDS completely from Pascal without
  2121. it.
  2122.  
  2123. æKY BuildDDPwds
  2124. æFp Appletalk.p
  2125. æT PROCEDURE
  2126. æD PROCEDURE BuildDDPwds(wdsPtr: Ptr;headerPtr: Ptr;dataPtr: Ptr;netAddr: AddrBlock;
  2127.     ddpType: INTEGER;dataLen: INTEGER);
  2128. æDT BuildDDPwds(wdsPtr,headerPtr,dataPtr,netAddr,ddpType,dataLen);
  2129. æRI BuildDDPwds procedure  V-514
  2130. æC 
  2131. This routine builds a single-frame write data structure  DDP WDS, for use with the
  2132. PWriteDDP call.  Given a header buffer of at least 17 bytes pointed to by headerPtr
  2133. and a data buffer of length dataLen pointed to by dataPtr, it fills in the WDS pointed
  2134. to by wdsPtr, and sets the destination address and protocol type as indicated by
  2135. destaddress and DDPtype, respectively.  The WDS indicated must contain at least 3
  2136. elements.
  2137.  
  2138. æKY BuildLAPwds
  2139. æFp Appletalk.p
  2140. æT PROCEDURE
  2141. æD PROCEDURE BuildLAPwds(wdsPtr: Ptr;dataPtr: Ptr;destHost: INTEGER;prototype: INTEGER;
  2142.     frameLen: INTEGER);
  2143. æDT BuildLAPwds(wdsPtr,dataPtr,destHost,prototype,frameLen);
  2144. æRI BuildLAPwds procedure  V-514
  2145. æC 
  2146. This routine builds a single-frame write data structure LAP WDS for use with the
  2147. PWriteLAP call.  Given a buffer of length frameLen pointed to by dataPtr, it fills in
  2148. the WDS pointed to by wdsPtr and sets the destination node and protocol type as
  2149. indicated by destHost and protoType, respectively.  The WDS indicated must contain at
  2150. least two elements.
  2151.  
  2152. æKY DDPchecksumFlag
  2153. æFp Appletalk.p
  2154. æC DDPchecksumFlag = DDP.checksumFlag;
  2155.  
  2156. æKY DDPCloseSocket
  2157. æFp Appletalk.p
  2158. æT FUNCTION
  2159. æD FUNCTION DDPCloseSocket(theSocket: Byte): OSErr;
  2160. æDT myVariable := DDPCloseSocket(theSocket);
  2161. æMM   
  2162. æRI DDPCloseSocket function  II-282
  2163. æC 
  2164. DDPCloseSocket removes the entry of the specified socket from the socket table and
  2165. cancels all pending DDPRead calls that have been made for that socket. If you pass a
  2166. socket number of 0, or if you attempt to close a socket that isn’t open, DDPCloseSocket
  2167. will return ddpSktErr.
  2168.  
  2169. Result codes    noErr        No error
  2170.                 ddpSktErr    Socket error
  2171.  
  2172. æKY DDPlistener
  2173. æFp Appletalk.p
  2174. æC DDPlistener = DDP.DDPptrs.listener;
  2175.  
  2176. æKY DDPOpenSocket
  2177. æFp Appletalk.p
  2178. æT FUNCTION
  2179. æD FUNCTION DDPOpenSocket(VAR theSocket: Byte;sktListener: Ptr): OSErr;
  2180. æDT myVariable := DDPOpenSocket(theSocket,sktListener);
  2181. æMM   
  2182. æRI DDPOpenSocket function  II-282
  2183. æC 
  2184. DDPOpenSocket adds a socket and its socket listener to the socket table. If theSocket
  2185. is nonzero, it must be in the range 64 to 127, and it specifies the socket’s number;
  2186. if theSocket is 0, DDPOpenSocket dynamically assigns a socket number in the range 128
  2187. to 254, and returns it in theSocket. SktListener contains a pointer to the socket
  2188. listener; if it’s NIL, the default listener will be used.
  2189.  
  2190. If you’re using the default socket listener, you must then call DDPRead to receive a
  2191. datagram (in order to specify buffer space for the default socket listener). If,
  2192. however, you’ve written your own socket listener and sktListener points to it, your
  2193. listener will provide buffers for receiving datagrams and you shouldn’t use DDPRead
  2194. calls.
  2195.  
  2196. DDPOpenSocket will return ddpSktErr if you pass the number of an already opened
  2197. socket, if you pass a socket number greater than 127, or if the socket table is
  2198. full.
  2199.  
  2200. Note:  The range of static socket numbers 1 through 63 is reserved by Apple
  2201.        for internal use. Socket numbers 64 through 127 are available for
  2202.        unrestricted experimental use.
  2203.  
  2204. Result codes    noErr        No error
  2205.                 ddpSktErr    Socket error
  2206.  
  2207. æKY DDPRdCancel
  2208. æFp Appletalk.p
  2209. æT FUNCTION
  2210. æD FUNCTION DDPRdCancel(abRecord: ABRecHandle): OSErr;
  2211. æDT myVariable := DDPRdCancel(abRecord);
  2212. æMM   
  2213. æRI DDPRdCancel function  II-284
  2214. æC 
  2215. Given the handle to the ABusRecord of a previously made DDPRead call, DDPRdCancel
  2216. dequeues the DDPRead call, provided that a packet satisfying the DDPRead hasn’t
  2217. already arrived. DDPRdCancel returns noErr if the DDPRead call is successfully removed
  2218. from the queue. If DDPRdCancel returns recNotFnd, check the abResult field of abRecord
  2219. to verify that the DDPRead has been completed and determine its outcome.
  2220.  
  2221. Result codes    noErr        No error
  2222.                 readQErr     Invalid socket or socket not found in table
  2223.                 recNotFnd    ABRecord not found in queue
  2224.  
  2225. »Example
  2226.  
  2227. This example sends a DDP packet synchronously and waits asynchronously for a response.
  2228. Assume that both nodes are using a known socket number (in this case, 30) to receive
  2229. packets. Normally, you would want to use NBP to look up your destination’s socket
  2230. address.
  2231.  
  2232. VAR
  2233.   myABRecord: ABRecHandle;
  2234.   myBuffer: PACKED ARRAY [0..599] OF CHAR; {buffer for both send and receive}
  2235.   mySocket: Byte;
  2236.   errCode, index, dataLen: INTEGER;
  2237.   someText: Str255;
  2238.   async, retCksumErrs, doChecksum: BOOLEAN;
  2239.  
  2240. BEGIN
  2241.   errCode := MPPOpen;
  2242.   IF errCode <> noErr THEN
  2243.     WRITELN('Error in opening AppleTalk')
  2244.     {Maybe serial port B isn't available for use by AppleTalk}
  2245.   ELSE
  2246.     BEGIN
  2247.       {Call Memory Manager to allocate ABusRecord}
  2248.       myABRecord := ABRecHandle(NewHandle(ddpSize));
  2249.       mySocket := 30;
  2250.   {Add mySocket to socket table and install default socket listener to service }
  2251. { datagrams addressed to that socket. No packets addressed to mySocket will be }
  2252.       { received until we call DDPRead. }
  2253.       errCode := DDPOpenSocket(mySocket, NIL);
  2254.       IF errCode <> noErr THEN
  2255.         WRITELN('Error while opening the socket')
  2256.       {Have we opened too many socket listeners? Remember that DDP uses two of }
  2257.         { them.}
  2258.       ELSE
  2259.         BEGIN
  2260.           {Prepare data to be sent}
  2261.           someText := 'This is a sample datagram';
  2262.           dataLen := LENGTH(someText);
  2263.           FOR index := 0 TO dataLen - 1 DO {stuff buffer with packet data}
  2264.             myBuffer[index] := someText[index + 1];
  2265.           async := FALSE;
  2266.           WITH myABRecord^^ DO {fill the parameters in the ABusRecord}
  2267.             BEGIN
  2268.               ddpType := 5;
  2269.               ddpAddress.aNet := 0; {send on “our” network}
  2270.               ddpAddress.aNode := 34;
  2271.               ddpAddress.aSocket := mySocket;
  2272.               ddpReqCount := dataLen;
  2273.               ddpDataPtr := @myBuffer;
  2274.             END;
  2275.           doChecksum := FALSE;
  2276.     {If packet contains a DDP long header, compute checksum and insert it into }
  2277.           { the header.}
  2278.           errCode := DDPWrite(myABRecord, doChecksum, async); {send packet}
  2279.      {In the case of a sync call, errCode and the abResult field of myABRecord }
  2280.    { will contain the same result code. We can also reuse myABRecord, since we }
  2281.           { know whether the call has completed.}
  2282.           IF errCode <> noErr THEN
  2283.             WRITELN('Error while writing out the packet')
  2284.             {Maybe the receiving node wasn't on-line}
  2285.           ELSE
  2286.             BEGIN
  2287.            {We have sent out the packet and are now waiting for a response. We }
  2288.            { issue an async DDPRead call so that we don't “hang” waiting for a }
  2289.           { response that may not come. To cancel the async read call, we must }
  2290.               { close the socket associated with the call or call DDPRdCancel.}
  2291.               async := TRUE;
  2292.               retCksumErrs := TRUE; {return packets even if }
  2293.                                     { they have a checksum error}
  2294.               WITH myABRecord^^ DO
  2295.                 BEGIN
  2296.                   ddpSocket := mySocket;
  2297.                   ddpReqCount := 600; {our reception buffer is max size}
  2298.                   ddpDataPtr := @myBuffer;
  2299.                 END;
  2300.               {Wait for a packet asynchronously}
  2301.               errCode := DDPRead(myABRecord, retCksumErrs, async);
  2302.               IF errCode <> noErr THEN
  2303.                 WRITELN('Error while trying to queue up a DDPRead')
  2304.                 {Was the socket listener installed correctly?}
  2305.               ELSE
  2306.                 BEGIN
  2307.                   {We can either sit here in a loop and poll the }
  2308.                   { abResult field or just exit our code and use the }
  2309.                   { event mechanism to flag us when the packet arrives.}
  2310.                   CheckForMyEvent; {your procedure for checking for a }
  2311.                                    { network event}
  2312.                   {If there were no errors, a packet is inside the array }
  2313.                   { mybuffer, the length is in ddpActCount, and the }
  2314.                   { address of the sending socket is in ddpAddress. }
  2315.                   { Process the packet received here and report any errors.}
  2316.                   errCode := DDPCloseSocket(mySocket); {we're done with it}
  2317.                   IF errCode <> noErr THEN
  2318.                     WRITELN('Error while closing the socket');
  2319.                 END;
  2320.             END;
  2321.         END;
  2322.     END;
  2323. END.
  2324.  
  2325.  
  2326. æKY DDPRead
  2327. æFp Appletalk.p
  2328. æT FUNCTION
  2329. æD FUNCTION DDPRead(abRecord: ABRecHandle;retCksumErrs: BOOLEAN;async: BOOLEAN): OSErr;
  2330. æDT myVariable := DDPRead(abRecord,retCksumErrs,async);
  2331. æMM   
  2332. æRI DDPRead function  II-283
  2333. æC 
  2334. ABusRecord
  2335.   <--    abOpcode         {always tDDPRead}
  2336.   <--    abResult         {result code}
  2337.   -->    abUserReference  {for your use}
  2338.   <--    ddpType          {DDP protocol type}
  2339.   -->    ddpSocket        {listening socket number}
  2340.   <--    ddpAddress       {source socket address}
  2341.   -->    ddpReqCount      {buffer size in bytes}
  2342.   <--    ddpActCount      {number of bytes actually received}
  2343.   -->    ddpDataPtr       {pointer to buffer}
  2344.   <--    ddpNodeID        {original destination node ID}
  2345.  
  2346. DDPRead receives a datagram from another socket. The size and location of the buffer
  2347. that will receive the data are specified by ddpReqCount and ddpDataPtr. If the buffer
  2348. isn’t large enough to hold all of the incoming frame data, the extra bytes will be
  2349. discarded and buf2SmallErr will be returned. The number of bytes actually received is
  2350. returned in ddpActCount. DDPSocket specifies the socket to receive the datagram (the
  2351. “listening” socket). The node to which the packet was sent is returned in ddpNodeID;
  2352. if the packet was broadcast ddpNodeID will contain 255. The address of the socket
  2353. that sent the packet is returned in ddpAddress. If retCksumErrs is FALSE, DDPRead
  2354. will discard any packets received with an invalid checksum and inform the caller of
  2355. the error. If retCksumErrs is TRUE, DDPRead will deliver all packets, whether or not
  2356. the checksum is valid; it will also notify the caller when there’s a checksum error.
  2357.  
  2358. Note:  The sender of the datagram must be in a different node from the
  2359.        receiver. You should issue DDPRead calls only for receiving datagrams
  2360.        for sockets opened with the default socket listener; see the
  2361.        description of DDPOpenSocket.
  2362.  
  2363. Note:  If the buffer provided isn’t large enough to hold all of the incoming
  2364.        frame data (buf2SmallErr), the checksum can’t be calculated; in this
  2365.        case, DDPRead will deliver packets even if retCksumErrs is FALSE.
  2366.  
  2367. Result codes    noErr           No error
  2368.                 buf2SmallErr    Datagram too large for buffer
  2369.                 cksumErr        Checksum error
  2370.                 ddpLenErr       Datagram length too big
  2371.                 ddpSktErr       Socket error
  2372.                 readQErr        Invalid socket or socket not found in table
  2373.  
  2374. æKY DDPsocket
  2375. æFp Appletalk.p
  2376. æC DDPsocket = DDP.socket;
  2377.  
  2378. æKY DDPwdsPointer
  2379. æFp Appletalk.p
  2380. æC DDPwdsPointer = DDP.DDPptrs.wdsPointer;
  2381.  
  2382. æKY DDPWrite
  2383. æFp Appletalk.p
  2384. æT FUNCTION
  2385. æD FUNCTION DDPWrite(abRecord: ABRecHandle;doChecksum: BOOLEAN;async: BOOLEAN): OSErr;
  2386. æDT myVariable := DDPWrite(abRecord,doChecksum,async);
  2387. æMM   
  2388. æRI DDPWrite function  II-283
  2389. æC  
  2390. ABusRecord
  2391.   <--    abOpcode         {always tDDPWrite}
  2392.   <--    abResult         {result code}
  2393.   -->    abUserReference  {for your use}
  2394.   -->    ddpType          {DDP protocol type}
  2395.   -->    ddpSocket        {source socket number}
  2396.   -->    ddpAddress       {destination socket address}
  2397.   -->    ddpReqCount      {length of datagram data}
  2398.   -->    ddpDataPtr       {pointer to buffer}
  2399.  
  2400. DDPWrite sends a datagram to another socket. DDPReqCount and ddpDataPtr specify the
  2401. length and location of the data to send. The ddpType field indicates the DDP protocol
  2402. type of the frame, and ddpAddress is the complete internet address of the socket to
  2403. which the datagram should be sent. DDPSocket specifies the socket from which the
  2404. datagram should be sent. Datagrams sent over the internet to a node on an AppleTalk
  2405. network different from the sending node’s network have an optional software checksum
  2406. to detect errors that might occur inside the intermediate bridges. If doChecksum is
  2407. TRUE, DDPWrite will compute this checksum; if it’s FALSE, this software checksum
  2408. feature is ignored.
  2409.  
  2410. Note:  The destination socket can’t be in the same node as the program
  2411.        making the DDPWrite call.
  2412.  
  2413. Result codes    noErr          No error
  2414.                 ddpLenErr      Datagram length too big
  2415.                 ddpSktErr      Source socket not open
  2416.                 noBridgeErr    No bridge found
  2417.  
  2418. æKY EntityName
  2419. æFp AppleTalk.p
  2420. æT RECORD
  2421. æC EntityName = RECORD
  2422.    objStr: Str32;
  2423.    typeStr: Str32;
  2424.    zoneStr: Str32;
  2425.    END;
  2426. { Real definition of EntityName is 3 PACKED strings of any length (32 is just an 
  2427. example). No offsets for Asm since each String address must be calculated by adding 
  2428. length byte to last string ptr. 
  2429. In Pascal, String(32) will be 34 bytes long since fields never start on an odd byte 
  2430. unless they are only a byte long. So this will generate correct looking interfaces for 
  2431. Pascal and C, but they will not be the same, which is OK since they are not used. }
  2432.  
  2433. æKY EntityPtr
  2434. æFp AppleTalk.p
  2435. æT TYPE
  2436. æC EntityPtr = ^EntityName;
  2437. EntityName = RECORD
  2438.    objStr: Str32;
  2439.    typeStr: Str32;
  2440.    zoneStr: Str32;
  2441.    END;
  2442. { Real definition of EntityName is 3 PACKED strings of any length (32 is just an 
  2443. example). No offsets for Asm since each String address must be calculated by adding 
  2444. length byte to last string ptr. 
  2445. In Pascal, String(32) will be 34 bytes long since fields never start on an odd byte 
  2446. unless they are only a byte long. So this will generate correct looking interfaces for 
  2447. Pascal and C, but they will not be the same, which is OK since they are not used. }
  2448.  
  2449. æKY GetBridgeAddress
  2450. æFp Appletalk.p
  2451. æT FUNCTION
  2452. æD FUNCTION GetBridgeAddress: INTEGER;
  2453. æDT myVariable := GetBridgeAddress;
  2454. æRT 132
  2455. æRI GetBridgeAddress function  V-515, N132-2
  2456. æC 
  2457. This routine returns the current address of a bridge in the low byte, or zero if
  2458. there is none.
  2459.  
  2460. æKY GetNodeAddress
  2461. æFp Appletalk.p
  2462. æT FUNCTION
  2463. æD FUNCTION GetNodeAddress(VAR myNode: INTEGER;VAR myNet: INTEGER): OSErr;
  2464. æDT myVariable := GetNodeAddress(myNode,myNet);
  2465. æRI GetNodeAddress function  II-303
  2466. æC 
  2467. GetNodeAddress returns the current node ID and network number of the caller. If the
  2468. .MPP driver isn’t installed, it returns noMPPErr. If myNet contains 0, this means
  2469. that a bridge hasn’t yet been found.
  2470.  
  2471. Result codes    noErr       No error
  2472.                 noMPPErr    MPP driver not installed
  2473.  
  2474. æKY IsATPOpen
  2475. æFp Appletalk.p
  2476. æT FUNCTION
  2477. æD FUNCTION IsATPOpen: BOOLEAN;
  2478. æDT myVariable := IsATPOpen;
  2479. æRI IsATPOpen function II-304
  2480. æC 
  2481. [Not in ROM]
  2482.  
  2483. IsATPOpen returns TRUE if the .ATP driver is loaded and running.
  2484.  
  2485. æKY IsMPPOpen
  2486. æFp Appletalk.p
  2487. æT FUNCTION
  2488. æD FUNCTION IsMPPOpen: BOOLEAN;
  2489. æDT myVariable := IsMPPOpen;
  2490. æRI IsMPPOpen function II-304
  2491. æC 
  2492. [Not in ROM]
  2493.  
  2494. IsMPPOpen returns TRUE if the .MPP driver is loaded and running.
  2495.  
  2496.  
  2497. æKY LAPAdrBlock
  2498. æFp AppleTalk.p
  2499. æT PACKED RECORD
  2500. æC LAPAdrBlock = PACKED RECORD
  2501.    dstNodeID: Byte;
  2502.    srcNodeID: Byte;
  2503.    lapProtType: ABByte;
  2504.    END;
  2505.  
  2506. æKY LAPCloseProtocol
  2507. æFp Appletalk.p
  2508. æT FUNCTION
  2509. æD FUNCTION LAPCloseProtocol(theLAPType: ABByte): OSErr;
  2510. æDT myVariable := LAPCloseProtocol(theLAPType);
  2511. æMM   
  2512. æRI LAPCloseProtocol function  II-277
  2513. æC 
  2514. LAPCloseProtocol removes from the node’s protocol table the specified ALAP protocol
  2515. type, as well as its protocol handler.
  2516.  
  2517. Warning:  Don’t close ALAP protocol type values 1 or 2. If you close these
  2518.           protocol types, DDP will be disabled; once disabled, the only way
  2519.           to restore DDP is to restart the system, or to close and then
  2520.           reopen AppleTalk.
  2521.  
  2522. Result codes    noErr         No error
  2523.                 lapProtErr    Error detaching protocol type
  2524.  
  2525. æKY LAPhandler
  2526. æFp Appletalk.p
  2527. æC LAPhandler = LAP.LAPptrs.handler;
  2528.  
  2529. æKY LAPOpenProtocol
  2530. æFp Appletalk.p
  2531. æT FUNCTION
  2532. æD FUNCTION LAPOpenProtocol(theLAPType: ABByte;protoPtr: Ptr): OSErr;
  2533. æDT myVariable := LAPOpenProtocol(theLAPType,protoPtr);
  2534. æMM   
  2535. æRI LAPOpenProtocol function  II-277
  2536. æC 
  2537. LAPOpenProtocol adds the ALAP protocol type specified by theLAPType to the
  2538. node’s protocol table. If you provide a pointer to a protocol handler in protoPtr,
  2539. ALAP will send each frame with an ALAP protocol type of theLAPType to that protocol
  2540. handler.
  2541.  
  2542. If protoPtr is NIL, the default protocol handler will be used for receiving frames
  2543. with an ALAP protocol type of theLAPType. In this case, to receive a frame you must
  2544. call LAPRead to provide the default protocol handler with a buffer for placing the
  2545. data. If, however, you’ve written your own protocol handler and protoPtr points to
  2546. it, your protocol handler will have the responsibility for receiving the frame and
  2547. it’s not necessary to call LAPRead.
  2548.  
  2549. Result codes    noErr         No error
  2550.                 lapProtErr    Error attaching protocol type
  2551.  
  2552. æKY LAPprotType
  2553. æFp Appletalk.p
  2554. æC LAPprotType = LAP.protType;
  2555.  
  2556. æKY LAPRdCancel
  2557. æFp Appletalk.p
  2558. æT FUNCTION
  2559. æD FUNCTION LAPRdCancel(abRecord: ABRecHandle): OSErr;
  2560. æDT myVariable := LAPRdCancel(abRecord);
  2561. æMM   
  2562. æRI LAPRdCancel function  II-279
  2563. æC 
  2564. Given the handle to the ABusRecord of a previously made LAPRead call, LAPRdCancel
  2565. dequeues the LAPRead call, provided that a packet satisfying the LAPRead has not
  2566. already arrived. LAPRdCancel returns noErr if the LAPRead call is successfully removed
  2567. from the queue. If LAPRdCancel returns recNotFnd, check the abResult field to verify
  2568. that the LAPRead has been completed and determine its outcome.
  2569.  
  2570. Result codes    noErr        No error
  2571.                 readQErr     Invalid protocol type or protocol type not
  2572.                              found in table
  2573.                 recNotFnd    ABRecord not found in queue
  2574.  
  2575. »Example
  2576.  
  2577. This example sends an ALAP packet synchronously and waits asynchronously for a response.
  2578. Assume that both nodes are using a known protocol type (in this case, 73) to receive
  2579. packets, and that the destination node has a node ID of 4.
  2580.  
  2581. VAR
  2582.   myABRecord: ABRecHandle;
  2583.   myBuffer: PACKED ARRAY [0..599] OF CHAR; {buffer for both send and receive}
  2584.   myLAPType: Byte;
  2585.   errCode, index, dataLen: INTEGER;
  2586.   someText: Str255;
  2587.   async: BOOLEAN;
  2588.  
  2589. BEGIN
  2590.   errCode := MPPOpen;
  2591.   IF errCode <> noErr THEN
  2592.     WRITELN('Error in opening AppleTalk')
  2593.     {Maybe serial port B isn't available for use by AppleTalk}
  2594.   ELSE
  2595.     BEGIN
  2596.     {Call Memory Manager to allocate ABusRecord}
  2597.     myABRecord := ABRecHandle(NewHandle(lapSize));
  2598.     myLAPType := 73;
  2599.    {Enter myLAPType into protocol handler table and install default handler to }
  2600.     { service frames of that ALAP type. No packets of that ALAP type will be }
  2601.     { received until we call LAPRead.}
  2602.     errCode := LAPOpenProtocol(myLAPType, NIL);
  2603.     IF errCode <> noErr THEN
  2604.       WRITELN('Error while opening the protocol type')
  2605.       {Have we opened too many protocol types? Remember that DDP uses two of }
  2606.       { them.}
  2607.     ELSE
  2608.       BEGIN
  2609.       {Prepare data to be sent}
  2610.       someText := 'This data will be in the ALAP data area';
  2611.       {The .MPP implementation requires that the first two bytes of the ALAP }
  2612.       { data field contain the length of the data, including the length bytes }
  2613.       { themselves.}
  2614.       dataLen := LENGTH(someText) + 2;
  2615.       buffer[0] := CHR(dataLen DIV 256); {high byte of data length}
  2616.       buffer[1] := CHR(dataLen MOD 256); {low byte of data length}
  2617.       FOR index := 1 TO dataLen - 2 DO {stuff buffer with packet data}
  2618.         buffer[index + 1] := someText[index];
  2619.       async := FALSE;
  2620.       WITH myABRecord^^ DO {fill parameters in the ABusRecord}
  2621.         BEGIN
  2622.         lapAddress.lapProtType := myLAPType;
  2623.         lapAddress.dstNodeID := 4;
  2624.         lapReqCount := dataLen;
  2625.         lapDataPtr := @buffer;
  2626.         END;
  2627.       {Send the frame}
  2628.       errCode := LAPWrite(myABRecord, async);
  2629.       {In the case of a sync call, errCode and the abResult field of }
  2630.       { the myABRecord will contain the same result code. We can also }
  2631.       { reuse myABRecord, since we know whether the call has completed.}
  2632.       IF errCode <> noErr THEN
  2633.         WRITELN('Error while writing out the packet')
  2634.         {Maybe the receiving node wasn't on-line}
  2635.       ELSE
  2636.         BEGIN
  2637.         {We have sent out the packet and are now waiting for a response. We }
  2638.         { issue an async LAPRead call so that we don't “hang” waiting for a }
  2639.         { response that may not come.}
  2640.         async := TRUE;
  2641.         WITH myABRecord^^ DO
  2642.           BEGIN
  2643.           lapAddress.lapProtType := myLAPType;
  2644.           {ALAP type we want to receive }
  2645.           lapReqCount := 600; {our buffer is maximum size}
  2646.           lapDataPtr := @buffer;
  2647.           END;
  2648.         errCode := LAPRead(myABRecord, async); {wait for a packet}
  2649.         IF errCode <> noErr THEN
  2650.           WRITELN('Error while trying to queue up a LAPRead')
  2651.           {Was the protocol handler installed correctly?}
  2652.         ELSE
  2653.           BEGIN
  2654.           {We can either sit here in a loop and poll the abResult }
  2655.           { field or just exit our code and use the event }
  2656.           { mechanism to flag us when the packet arrives.}
  2657.           CheckForMyEvent; {your procedure for checking for a network event}
  2658.           errCode := LAPCloseProtocol(myLAPType);
  2659.           IF errCode <> noErr THEN
  2660.             WRITELN('Error while closing the protocol type');
  2661.           END;
  2662.         END;
  2663.       END;
  2664.     END;
  2665. END.
  2666.  
  2667. æKY LAPRead
  2668. æFp Appletalk.p
  2669. æT FUNCTION
  2670. æD FUNCTION LAPRead(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  2671. æDT myVariable := LAPRead(abRecord,async);
  2672. æMM   
  2673. æRI LAPRead function  II-278
  2674. æC  
  2675. ABusRecord
  2676.   <--    abOpcode                {always tLAPRead}
  2677.   <--    abResult                {result code}
  2678.   -->    abUserReference         {for your use}
  2679.   <--    lapAddress.dstNodeID    {destination node ID}
  2680.   <--    lapAddress.srcNodeID    {source node ID}
  2681.   -->    lapAddress.lapProtType  {ALAP protocol type}
  2682.   -->    lapReqCount             {buffer size in bytes}
  2683.   <--    lapActCount             {number of frame data bytes actually received}
  2684.   -->    lapDataPtr              {pointer to buffer}
  2685.  
  2686. LAPRead receives a frame from another node. LAPReqCount and lapDataPtr specify the
  2687. size and location of the buffer that will receive the frame data. If the buffer isn’t
  2688. large enough to hold all of the incoming frame data, the extra bytes will be discarded
  2689. and buf2SmallErr will be returned. The number of bytes actually received is returned
  2690. in lapActCount. Only frames with ALAP protocol type equal to lapAddress.lapProtType
  2691. will be received. The node IDs of the frame’s source and destination nodes are returned
  2692. in lapAddress.srcNodeID and lapAddress.dstNodeID. You can determine whether the
  2693. packet was broadcast to you by examining the value of lapAddress.dstNodeID—if the
  2694. packet was broadcast it’s equal to 255, otherwise it’s equal to your node ID.
  2695.  
  2696. Note:  You should issue LAPRead calls only for ALAP protocol types that were
  2697.        opened (via LAPOpenProtocol) to use the default protocol handler.
  2698.  
  2699. Warning:  If you close a protocol type for which there are still LAPRead
  2700.           calls pending, the calls will be canceled but the memory occupied
  2701.           by their ABusRecords will not be released. For this reason, before
  2702.           closing a protocol type, call LAPRdCancel to cancel any pending
  2703.           LAPRead calls associated with that protocol type.
  2704.  
  2705. Result codes    noErr           No error
  2706.                 buf2SmallErr    Frame too large for buffer
  2707.                 readQErr        Invalid protocol type or protocol type not
  2708.                                 found in table
  2709.  
  2710. æKY lapSize,ddpSize,nbpSize,atpSize
  2711. æFp Appletalk.p
  2712. æC 
  2713.   lapSize = 20;   {ABusRecord size for ALAP}
  2714.   ddpSize = 26;   {ABusRecord size for DDP}
  2715.   nbpSize = 26;   {ABusRecord size for NBP}
  2716.   atpSize = 56;   {ABusRecord size for ATP}
  2717.  
  2718. æKY LAPwdsPointer
  2719. æFp Appletalk.p
  2720. æC LAPwdsPointer = LAP.LAPptrs.wdsPointer;
  2721.  
  2722. æKY LAPWrite
  2723. æFp Appletalk.p
  2724. æT FUNCTION
  2725. æD FUNCTION LAPWrite(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  2726. æDT myVariable := LAPWrite(abRecord,async);
  2727. æMM   
  2728. æRI LAPWrite function  II-277
  2729. æC 
  2730. ABusRecord
  2731.   <--    abOpcode                {always tLAPWrite}
  2732.   <--    abResult                {result code}
  2733.   -->    abUserReference         {for your use}
  2734.   -->    lapAddress.dstNodeID    {destination node ID}
  2735.   -->    lapAddress.lapProtType  {ALAP protocol type}
  2736.   -->    lapReqCount             {length of frame data}
  2737.   -->    lapDataPtr              {pointer to frame data}
  2738.  
  2739. LAPWrite sends a frame to another node. LAPReqCount and lapDataPtr specify the length
  2740. and location of the data to send. The lapAddress.lapProtType field indicates the ALAP
  2741. protocol type of the frame and the lapAddress.dstNodeID indicates the node ID of the
  2742. node to which the frame should be sent.
  2743.  
  2744. Note:  The first two bytes of an ALAP frame’s data must contain the length
  2745.        in bytes of that data, including the length bytes themselves.
  2746.  
  2747. Result codes    noErr            No error
  2748.                 excessCollsns    Unable to contact destination node;
  2749.                                  packet not sent
  2750.                 ddpLenErr        ALAP data length too big
  2751.                 lapProtErr       Invalid ALAP protocol type
  2752.  
  2753. æKY MPPClose
  2754. æFp Appletalk.p
  2755. æT FUNCTION
  2756. æD FUNCTION MPPClose: OSErr;
  2757. æDT myVariable := MPPClose;
  2758. æMM   
  2759. æRI MPPClose function  II-275
  2760. æC 
  2761. MPPClose removes the .MPP driver, and any data structures associated with it, from
  2762. memory. If the .ATP driver or NBP code were also installed, they’re removed as well.
  2763. MPPClose also returns the use of port B to the Serial Driver.
  2764.  
  2765. Warning:  Since other co-resident programs may be using AppleTalk, it’s
  2766.           strongly recommended that you never use this call. MPPClose will
  2767.           completely disable AppleTalk; the only way to restore AppleTalk
  2768.           is to call MPPOpen again.
  2769.  
  2770. æKY MPPcsCode
  2771. æFp Appletalk.p
  2772. æC MPPcsCode = MPP.csCode;
  2773.  
  2774. æKY MPPioCompletion
  2775. æFp Appletalk.p
  2776. æC MPPioCompletion = MPP.ioCompletion;
  2777.  
  2778. æKY MPPioRefNum
  2779. æFp Appletalk.p
  2780. æC MPPioRefNum = MPP.ioRefNum;
  2781.  
  2782. æKY MPPioResult
  2783. æFp Appletalk.p
  2784. æC MPPioResult = MPP.ioResult;
  2785.  
  2786. æKY MPPOpen
  2787. æFp Appletalk.p
  2788. æT FUNCTION
  2789. æD FUNCTION MPPOpen: OSErr;
  2790. æDT myVariable := MPPOpen;
  2791. æMM 
  2792. æRT 224
  2793. æRI MPPOpen function  II-275
  2794. æC 
  2795. MPPOpen first checks whether the .MPP driver has already been loaded; if it has,
  2796. MPPOpen does nothing and returns noErr. If MPP hasn’t been loaded, MPPOpen attempts
  2797. to load it into the system heap. If it succeeds, it then initializes the driver’s
  2798. variables and goes through the process of dynamically assigning a node ID to that
  2799. Macintosh. On a Macintosh 512K or XL, it also loads the .ATP driver and NBP code into
  2800. the system heap.
  2801.  
  2802. If serial port B isn’t configured for AppleTalk, or is already in use, the .MPP
  2803. driver isn’t loaded and an appropriate result code is returned.
  2804.  
  2805. Result codes    noErr        No error
  2806.                 portInUse    Port B is already in use
  2807.                 portNotCf    Port B not configured for AppleTalk
  2808.  
  2809. æKY NamesTableEntry
  2810. æFp AppleTalk.p
  2811. æT RECORD
  2812. æC NamesTableEntry = RECORD
  2813.    qLink: QElemPtr;
  2814.    nteAddress: AddrBlock;
  2815.    nteData: PACKED ARRAY [1..100] OF CHAR;
  2816.    END;
  2817.  
  2818. æKY NBPConfirm
  2819. æFp Appletalk.p
  2820. æT FUNCTION
  2821. æD FUNCTION NBPConfirm(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  2822. æDT myVariable := NBPConfirm(abRecord,async);
  2823. æMM 
  2824. æRT 9
  2825. æRI NBPConfirm function  II-301, N9-2
  2826. æC 
  2827. ABusRecord
  2828.   <--    abOpcode           {always tNBPConfirm}
  2829.   <--    abResult           {result code}
  2830.   -->    abUserReference    {for your use}
  2831.   -->    nbpEntityPtr       {pointer to entity name}
  2832.   <--    nbpDataField       {socket number}
  2833.   -->    nbpAddress         {socket address}
  2834.   -->    nbpRetransmitInfo  {retransmission information}
  2835.  
  2836. NBPConfirm confirms that an entity known by name and address still exists (is still
  2837. entered in the names directory). NBPEntityPtr points to a variable of type EntityName
  2838. that contains the name to confirm, and nbpAddress specifies the address to be confirmed.
  2839. (No meta-characters are allowed in the entity name.) NBPRetransmitInfo contains the
  2840. retry interval and the retry count. The socket number of the entity is returned in
  2841. nbpDataField. NBPConfirm is more efficient than NBPLookup in terms of network traffic.
  2842.  
  2843. Result codes    noErr           No error
  2844.                 nbpConfDiff     Name confirmed for different socket
  2845.                 nbpNoConfirm    Name not confirmed
  2846.  
  2847. æKY NBPconfirmAddr
  2848. æFp Appletalk.p
  2849. æC NBPconfirmAddr = NBP.parm.Confirm.confirmAddr;
  2850.  
  2851. æKY NBPcount
  2852. æFp Appletalk.p
  2853. æC NBPcount = NBP.count;
  2854.  
  2855. æKY NBPentityPtr
  2856. æFp Appletalk.p
  2857. æC NBPentityPtr = NBP.NBPPtrs.entityPtr;
  2858.  
  2859. æKY NBPExtract
  2860. æFp Appletalk.p
  2861. æT FUNCTION
  2862. æD FUNCTION NBPExtract(theBuffer: Ptr;numInBuf: INTEGER;whichOne: INTEGER;
  2863.     VAR abEntity: EntityName;VAR address: AddrBlock): OSErr;
  2864. æDT myVariable := NBPExtract(theBuffer,numInBuf,whichOne,abEntity,address);
  2865. æMM   
  2866. æRI NBPExtract function  II-300,V-515
  2867. æC 
  2868. This routine is provided in the alternate interface, but can be used as provided for
  2869. extracting NBP entity names from a look-up response buffer.
  2870.  
  2871. NBPExtract returns one address from the list of addresses returned by NBPLookup.
  2872. TheBuffer and numInBuf indicate the location and number of tuples in the buffer.
  2873. WhichOne specifies which one of the tuples in the buffer should be returned in the
  2874. abEntity and address parameters.
  2875.  
  2876. Result codes    noErr         No error
  2877.                 extractErr    Can’t find tuple in buffer
  2878.  
  2879. æKY NBPinterval
  2880. æFp Appletalk.p
  2881. æC NBPinterval = NBP.interval;
  2882.  
  2883. æKY NBPLoad
  2884. æFp Appletalk.p
  2885. æT FUNCTION
  2886. æD FUNCTION NBPLoad: OSErr;
  2887. æDT myVariable := NBPLoad;
  2888. æMM   
  2889. æRI NBPLoad function  II-301
  2890. æC 
  2891. On a Macintosh 128K, NBPLoad reads the NBP code from the system resource file into
  2892. the application heap. On a Macintosh 512K or XL, NBPLoad has no effect since the NBP
  2893. code should have already been loaded when the .MPP driver was opened. Normally you’ll
  2894. never need to call NBPLoad, because the AppleTalk Manager calls it when necessary.
  2895.  
  2896. Result codes    noErr    No error
  2897.  
  2898. æKY NBPLookup
  2899. æFp Appletalk.p
  2900. æT FUNCTION
  2901. æD FUNCTION NBPLookup(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  2902. æDT myVariable := NBPLookup(abRecord,async);
  2903. æMM 
  2904. æRT 9, 20
  2905. æRI NBPLookup function  II-300, N9-1, 2, N20-2 
  2906. æC 
  2907. ABusRecord
  2908.   <--    abOpcode           {always tNBPLookup}
  2909.   <--    abResult           {result code}
  2910.   -->    abUserReference    {for your use}
  2911.   -->    nbpEntityPtr       {pointer to entity name}
  2912.   -->    nbpBufPtr          {pointer to buffer}
  2913.   -->    nbpBufSize         {buffer size in bytes}
  2914.   <->    nbpDataField       {number of addresses received}
  2915.   -->    nbpRetransmitInfo  {retransmission information}
  2916.  
  2917. NBPLookup returns the addresses of all entities with a specified name. NBPEntityPtr
  2918. points to a variable of type EntityName containing the name of the entity whose
  2919. address should be returned. (Meta-characters are allowed in the entity name.) NBPBufPtr
  2920. and nbpBufSize contain the location and size of an area of memory in which the entity
  2921. names and their corresponding addresses should be returned. NBPDataField indicates
  2922. the maximum number of matching names to find addresses for; the actual number of
  2923. addresses found is returned in nbpDataField. NBPRetransmitInfo contains the retry
  2924. interval and the retry count.
  2925.  
  2926. When specifying nbpBufSize, for each NBP tuple expected, allow space for the actual
  2927. characters of the name, the address, and four bytes for use by NBP.
  2928.  
  2929. Result codes    noErr         No error
  2930.                 nbpBuffOvr    Buffer overflow
  2931.  
  2932. æKY NBPmaxToGet
  2933. æFp Appletalk.p
  2934. æC NBPmaxToGet = NBP.parm.Lookup.maxToGet;
  2935.  
  2936. æKY NBPnewSocket
  2937. æFp Appletalk.p
  2938. æC NBPnewSocket = NBP.parm.Confirm.newSocket;
  2939.  
  2940. æKY NBPnKillQEl
  2941. æFp Appletalk.p
  2942. æC NBPnKillQEl = NBPKILL.nKillQEl;
  2943.  
  2944. æKY NBPntQElPtr
  2945. æFp Appletalk.p
  2946. æC NBPntQElPtr = NBP.NBPPtrs.ntQElPtr;
  2947.  
  2948. æKY NBPnumGotten
  2949. æFp Appletalk.p
  2950. æC NBPnumGotten = NBP.parm.Lookup.numGotten;
  2951.  
  2952. æKY NBPRegister
  2953. æFp Appletalk.p
  2954. æT FUNCTION
  2955. æD FUNCTION NBPRegister(abRecord: ABRecHandle;async: BOOLEAN): OSErr;
  2956. æDT myVariable := NBPRegister(abRecord,async);
  2957. æMM 
  2958. æRT 20
  2959. æRI NBPRegister function  II-299, N20-2
  2960. æC 
  2961. ABusRecord
  2962.   <--    abOpcode            {always tNBPRegister}
  2963.   <--    abResult            {result code}
  2964.   -->    abUserReference     {for your use}
  2965.   -->    nbpEntityPtr        {pointer to entity name}
  2966.   -->    nbpBufPtr           {pointer to buffer}
  2967.   -->    nbpBufSize          {buffer size in bytes}
  2968.   -->    nbpAddress.aSocket  {socket address}
  2969.   -->    nbpRetransmitInfo   {retransmission information}
  2970.  
  2971. NBPRegister adds the name and address of an entity to the node’s names table. NBPEntityPtr
  2972. points to a variable of type EntityName containing the entity’s name. If the name is
  2973. already registered, NBPRegister returns the result code nbpDuplicate. NBPAddress
  2974. indicates the socket for which the name should be registered. NBPBufPtr and nbpBufSize
  2975. specify the location and size of a buffer for NBP to use internally.
  2976.  
  2977. While the variable of type EntityName is declared as three 32-byte strings, only the
  2978. actual characters of the name are placed in the buffer pointed to by nbpBufPtr. For
  2979. this reason, nbpBufSize needs only to be equal to the actual length of the name, plus
  2980. an additional 12 bytes for use by NBP.
  2981.  
  2982. Warning:  This buffer must not be altered or released until the name is
  2983.           removed from the names table via an NBPRemove call. If you
  2984.           allocate the buffer through a NewHandle call, you must lock
  2985.           it as long as the name is registered.
  2986.  
  2987. Warning:  The zone field of the entity name must be set to the
  2988.           meta-character “*”.
  2989.  
  2990. Result codes    noErr           No error
  2991.                 nbpDuplicate    Duplicate name already exists
  2992.  
  2993. æKY NBPRemove
  2994. æFp Appletalk.p
  2995. æT FUNCTION
  2996. æD FUNCTION NBPRemove(abEntity: EntityPtr): OSErr;
  2997. æDT myVariable := NBPRemove(abEntity);
  2998. æMM   
  2999. æRI NBPRemove function  II-301
  3000. æC 
  3001. NBPRemove removes an entity name from the names table of the given entity’s node.
  3002.  
  3003. Result codes    noErr          No error
  3004.                 nbpNotFound    Name not found
  3005.  
  3006. æKY NBPretBuffPtr
  3007. æFp Appletalk.p
  3008. æC NBPretBuffPtr = NBP.parm.Lookup.retBuffPtr;
  3009.  
  3010. æKY NBPretBuffSize
  3011. æFp Appletalk.p
  3012. æC NBPretBuffSize = NBP.parm.Lookup.retBuffSize;
  3013.  
  3014. æKY NBPSetEntity
  3015. æFp Appletalk.p
  3016. æT PROCEDURE
  3017. æD PROCEDURE NBPSetEntity(buffer: Ptr;nbpObject: Str32;nbpType: Str32;nbpZone: Str32);
  3018. æDT NBPSetEntity(buffer,nbpObject,nbpType,nbpZone);
  3019. æRI NBPSetEntity procedure  V-514
  3020. æC 
  3021. This routine builds an NBP entity structure, for use with the PLookupNBP and PConfirmName
  3022. calls.  Given a buffer of at least the size of the EntityName data structure (99
  3023. bytes) pointed to by buffer, this routine sets the indicated object, type, and zone
  3024. in that buffer.
  3025.  
  3026. æKY NBPSetNTE
  3027. æFp Appletalk.p
  3028. æT PROCEDURE
  3029. æD PROCEDURE NBPSetNTE(ntePtr: Ptr;nbpObject: Str32;nbpType: Str32;nbpZone: Str32;
  3030.     socket: INTEGER);
  3031. æDT NBPSetNTE(ntePtr,nbpObject,nbpType,nbpZone,socket);
  3032. æRI NBPSetNTE procedure  V-515
  3033. æC 
  3034. This routine builds an NBP names table entry, for use with the PRegisterName call. 
  3035. Given a names table entry of at least the size of the EntityName data structure plus
  3036. nine bytes (108 bytes) pointed to by ntePtr, this routine sets the indicated object,
  3037. type, zone, and socket in that names table entry.
  3038.  
  3039. æKY NBPUnload
  3040. æFp Appletalk.p
  3041. æT FUNCTION
  3042. æD FUNCTION NBPUnload: OSErr;
  3043. æDT myVariable := NBPUnload;
  3044. æMM   
  3045. æRI NBPUnload function  II-301
  3046. æC 
  3047. On a Macintosh 128K, NBPUnload makes the NBP code purgeable; the space isn’t actually
  3048. released by the Memory Manager until necessary. On a Macintosh 512K or Macintosh XL,
  3049. NBPUnload has no effect.
  3050.  
  3051. Result codes    noErr    No error
  3052.  
  3053. »Example
  3054.  
  3055. This example of NBP registers our node as a print spooler, searches for any print
  3056. spoolers registered on the network, and then extracts the information for the first
  3057. one found.
  3058.  
  3059. CONST
  3060.   mySocket = 20;
  3061.  
  3062. VAR
  3063.   myABRecord: ABRecHandle;
  3064.   myEntity: EntityName;
  3065.   entityAddr: AddrBlock;
  3066.   nbpNamePtr: Ptr;
  3067.   myBuffer: PACKED ARRAY [0..999] OF CHAR;
  3068.   errCode: INTEGER;
  3069.   async: BOOLEAN;
  3070.  
  3071. BEGIN
  3072.   errCode := MPPOpen;
  3073.   IF errCode <> noErr THEN
  3074.     WRITELN('Error in opening AppleTalk')
  3075.     {Maybe serial port B isn't available for use by AppleTalk}
  3076.   ELSE
  3077.     BEGIN
  3078.       {Call Memory Manager to allocate ABusRecord}
  3079.       myABRecord := ABRecHandle(NewHandle(nbpSize));
  3080.       {Set up our entity name to register}
  3081.       WITH myEntity DO
  3082.         BEGIN
  3083.           objStr := 'Gene Station'; {we are called 'Gene Station' }
  3084.           typeStr := 'PrintSpooler'; { and are of type 'PrintSpooler'}
  3085.           zoneStr := '*';
  3086.           {Allocate data space for the entity name (used by NBP)}
  3087.           nbpNamePtr := NewPtr(LENGTH(objStr) + LENGTH(typeStr) +
  3088.                                LENGTH(zoneStr) + 12);
  3089.         END;
  3090.       {Set up the ABusRecord for the NBPRegister call}
  3091.       WITH myABRecord^^ DO
  3092.         BEGIN
  3093.           nbpEntityPtr := @myEntity;
  3094.           nbpBufPtr := nbpNamePtr; {buffer used by NBP internally}
  3095.           nbpBufSize := nbpNameBufSize;
  3096.           nbpAddress.aSocket := mySocket; {socket to register us on}
  3097.           nbpRetransmitInfo.retransInterval := 8; {retransmit every 64 }
  3098.           nbpRetransmitInfo.retransCount := 3; { ticks and try 3 times}
  3099.         END;
  3100.       async := FALSE;
  3101.       errCode := NBPRegister(myABRecord, async);
  3102.       IF errCode <> noErr THEN
  3103.         WRITELN('Error occurred in the NBPRegister call')
  3104.         {Maybe the name is already registered somewhere else on the }
  3105.         { network.}
  3106.       ELSE
  3107.         BEGIN
  3108.           {Now that we've registered our name, find others of type }
  3109.           { 'PrintSpooler'.}
  3110.           WITH myEntity DO
  3111.             BEGIN
  3112.               objStr := '='; {any one of type }
  3113.               typeStr := 'PrintSpooler'; { “PrintSpooler” }
  3114.               zoneStr := '*'; { in our zone}
  3115.             END;
  3116.           WITH myABRecord^^ DO
  3117.             BEGIN
  3118.               nbpEntityPtr := @myEntity;
  3119.               nbpBufPtr := @myBuffer; {buffer to place responses in}
  3120.               nbpBufSize := SIZEOF(myBuffer);
  3121.              {The field nbpDataField, before the NBPLookup call, represents an }
  3122.               { approximate number of responses. After the call, nbpDataField }
  3123.               { contains the actual number of responses received.}
  3124.               nbpDataField := 100; {we want about 100 responses back}
  3125.             END;
  3126.           errCode := NBPLookup(myABRecord, async); {make sync call}
  3127.           IF errCode <> noErr THEN
  3128.             WRITELN('An error occurred in the NBPLookup')
  3129.             {Did the buffer overflow?}
  3130.           ELSE
  3131.             BEGIN
  3132.               {Get the first reply}
  3133.               errCode := NBPExtract(@mybuffer, myABRecord^^.nbpDataField, 1,
  3134.                                     myEntity, entityAddr);
  3135.            {The socket address and name of the entity are returned here. If we }
  3136.              { want all of them, we'll have to loop for each one in the buffer.}
  3137.               IF errCode <> noErr THEN WRITELN('Error in NBPExtract');
  3138.               {Maybe the one we wanted wasn't in the buffer}
  3139.             END;
  3140.         END;
  3141.     END;
  3142. END.
  3143.  
  3144.  
  3145. æKY NBPverifyFlag
  3146. æFp Appletalk.p
  3147. æC NBPverifyFlag = NBP.parm.verifyFlag;
  3148.  
  3149. æKY OpenXPP
  3150. æFp Appletalk.p
  3151. æT FUNCTION
  3152. æD FUNCTION OpenXPP(VAR xppRefnum: INTEGER): OSErr;
  3153. æDT myVariable := OpenXPP(xppRefnum);
  3154. æC 
  3155. »Opening the .XPP Driver
  3156.  
  3157. To open the .XPP driver, issue a Device Manager Open call.  (Refer to the Device
  3158. Manager chapter.)  The name of the .XPP driver is '.XPP'.  The original Macintosh
  3159. ROMs require that .XPP be opened only once. With new ROMs, the .XPP unit number can
  3160. always be obtained through an Open call.  With old ROMs only, the .XPP unit number
  3161. must be hard coded to XPPUnitNum (40) since only one Open call can be issued to the
  3162. driver.
  3163.  
  3164. The .XPP driver cannot be opened unless AppleTalk is open.  The application must
  3165. ensure that the .MPP and .ATP drivers are opened, as described earlier in this chapter.
  3166.  
  3167. The xppLoaded bit (bit 5) in the PortBUse byte in low memory indicates whether or not
  3168. the .XPP driver is open.
  3169.  
  3170. »Example
  3171.  
  3172. The following is an example of the procedure an application might use to open the
  3173. .XPP driver.
  3174.  
  3175. ;    Routine: OpenXPP
  3176. ;
  3177. ;        Open the .XPP driver and return the driver refNum for it.
  3178. ;
  3179. ;        Exit:    D0 = error code (ccr's set)
  3180. ;                 D1 = XPP driver refNum (if no errors)
  3181. ;
  3182. ;        All other registers preserved
  3183. ;
  3184. xppUnitNum    EQU    40                 ;default XPP driver number
  3185. xppTfRNum     EQU    -(xppUnitNum+1)    ;default XPP driver refNum
  3186.  
  3187. OpenXPP
  3188.     MOVE.L    A0-A1/D2,-(SP)            ;save registers
  3189.     MOVE      ROM85,D0                  ;check ROM type byte
  3190.     BPL.S     @10                       ;branch if >=128K ROMs
  3191.     BTST      #xppLoadedBit,PortBUse    ;is the XPP driver open already?
  3192.     BEQ.S     @10                       ;if not open, then branch to Open code
  3193.     MOVE      #xppTfRNum,D1             ;else use this as driver refnum
  3194.     MOVEQ     #0,D0                     ;set noErr
  3195.     BRA.S     @90                       ;and exit
  3196. ;
  3197. ; XPP driver not open. Make an _Open call to it. If using a 128K
  3198. ; ROM machine and the driver is already open, we will make another
  3199. ; Open call to it just so we get the correct driver refNum.
  3200. ;
  3201. @10 SUB       #ioQElSize,SP             ;allocate temporary param block
  3202.     MOVE.L    SP,A0                     ;A0 -> param block
  3203.     LEA       XPPName, A1               ;A1 -> XPP (ASP/AFP) driver name
  3204.     MOVE.L    A1,ioFileName(A0)         ;driver name into param block
  3205.     CLR.B     ioPermssn(A0)             ;clear permissions byte
  3206.     _Open
  3207.     MOVE      ioRefNum(A0),D1           ;D1=driver refNum (invalid if error)
  3208.     ADD       #ioQElSize,SP             ;deallocate temp param block
  3209. @90 MOVE.L    (SP)+,A0-A1/D2            ;restore registers
  3210.     TST       D0                        ;error? (set ccr's)
  3211.     RTS
  3212.     
  3213. XPPName  DC.B  4                        ;length of string
  3214.          DC.B  '.XPP'                   ;driver name
  3215.  
  3216. From Pascal, XPP can be opened through the OpenXPP call, which returns the driver’s
  3217. reference number:
  3218.  
  3219. FUNCTION OpenXPP (VAR xppRefnum: INTEGER) : OSErr;
  3220.  
  3221. »Open Errors
  3222.  
  3223. Errors returned when calling the Device Manager Open routine if the function does not
  3224. execute properly include the following:
  3225.  
  3226.   •  errors returned by System
  3227.   •  portInUse is returned if the AppleTalk port is in use by a driver
  3228.      other than AppleTalk or if AppleTalk is not open.
  3229.  
  3230. »Closing the .XPP Driver
  3231.  
  3232. To close the .XPP driver, call the Device Manager Close routine.
  3233.  
  3234. Warning:  There is generally no reason to close the driver.  Use this
  3235.           call sparingly, if at all.  This call should generally be used
  3236.           only by system-level applications.
  3237.  
  3238. »Close Errors
  3239.  
  3240. Errors returned when calling the Device Manager Close routine if the function does
  3241. not execute properly include the following:
  3242.  
  3243.   •  errors returned by System
  3244.   •  closeErr (new ROMs only) is returned if you try to close the driver
  3245.      and there are sessions active through that driver.  When sessions are
  3246.      active, closeErr is returned and the driver remains open.
  3247.   •  on old ROMs the driver is closed whether or not sessions are active
  3248.      and no error is returned. Results are unpredictable if sessions are
  3249.      still active.
  3250.  
  3251. »Session Control Block
  3252.  
  3253. The session control block (SCB) is a nonrelocatable block of data passed by the
  3254. caller to XPP upon session opening. XPP reserves this block for use in maintaining an
  3255. open session.   The SCB size is defined by the constant scbMemSize.  The SCB is a
  3256. locked block, and as long as the session is open, the SCB cannot be modified in any
  3257. way by the application.  There is one SCB for each open session. This block can be
  3258. reused once a CloseSess call is issued and completed for that session or when the
  3259. session is indicated as closed.
  3260.     
  3261.  
  3262. æKY PAddResponse
  3263. æFp Appletalk.p
  3264. æT FUNCTION
  3265. æD FUNCTION PAddResponse(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3266. æDT myVariable := PAddResponse(thePBPtr,async);
  3267. æRI AddResponse function II-318,V-513
  3268. æC AddResponse function
  3269.  
  3270. Parameter block
  3271.  
  3272.     ->  18  userData        long word   ;user bytes
  3273.     ->  26  csCode          word        ;always addResponse
  3274.     ->  28  atpSocket       byte        ;socket number
  3275.     ->  29  atpFlags        byte        ;control information
  3276.     ->  30  addrBlock       long word   ;response destination
  3277.     ->  34  reqLength       word        ;response size
  3278.     ->  36  reqPointer      pointer     ;pointer to response
  3279.     ->  44  rspNum          byte        ;sequence number
  3280.     ->  46  transID         word        ;transaction ID
  3281.  
  3282. AddResponse sends an additional response packet to a socket that has already been 
  3283. sent the initial part of a response via SendResponse.  UserData contains the four 
  3284. user bytes.  ATPSocket contains the socket number from which the response should 
  3285. be sent.  The end-of-message flag in atpFlags should be set if this response packet 
  3286. is the final packet in a transaction composed of a group of packets and the number 
  3287. of responses is less than requested.  AddrBlock indicates the socket to which the 
  3288. response should be sent.  ReqLength and reqPointer contain the size (in bytes) and 
  3289. location of the response to send; rspNum indicates the sequence number of the 
  3290. response (in the range 0 to 7).  TransID must contain the transaction ID.
  3291.  
  3292. Warning:  If the transaction is part of an exactly-once transaction, the buffer 
  3293.           used in the AddResponse call must not be altered or released until the 
  3294.           corresponding SendResponse call has completed. 
  3295.  
  3296. Result codes    
  3297.  
  3298.       noErr           No error
  3299.       badATPSkt       Bad responding socket
  3300.       noSendResp      AddResponse issued before SendResponse
  3301.       badBuffNum      Sequence number out of range
  3302.       noDataArea      Too many outstanding ATP calls
  3303.  
  3304. æKY PAttachPH
  3305. æFp Appletalk.p
  3306. æT FUNCTION
  3307. æD FUNCTION PAttachPH(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3308. æDT myVariable := PAttachPH(thePBptr,async);
  3309. æRI AttachPH function II-308, V-513
  3310.  
  3311. æC AttachPH function
  3312.  
  3313. Parameter block
  3314.     ->  26  csCode        word     ;always attachPH
  3315.     ->  28  protType      byte     ;ALAP protocol type
  3316.     ->  30  handler       pointer  ;protocol handler
  3317.  
  3318. AttachPH adds the protocol handler pointed to by handler to the node's protocol 
  3319. table.  ProtType specifies what kind of frame the protocol handler can service.  
  3320.  
  3321. After AttachPH is called, the protocol handler is called for each incoming frame 
  3322. whose ALAP protocol type equals protType.
  3323.  
  3324. Result codes    
  3325.  
  3326.    noErr         No error
  3327.    lapProtErr    Error attaching protocol type
  3328.  
  3329. æKY PCloseATPSkt
  3330. æFp Appletalk.p
  3331. æT FUNCTION
  3332. æD FUNCTION PCloseATPSkt(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3333. æDT myVariable := PCloseATPSkt(thePBPtr,async);
  3334. æRI CloseATPSkt function II-316,V-513
  3335. æC CloseATPSkt function
  3336.  
  3337. Parameter block
  3338.     ->  26  csCode     word ;always closeATPSkt
  3339.     ->  28  atpSocket   byte    ;socket number
  3340.  
  3341. CloseATPSkt closes the socket whose number is specified by atpSocket, for the 
  3342. purpose of receiving requests.
  3343.  
  3344. Result codes    
  3345.    noErr      No error
  3346.  
  3347. æKY PCloseSkt
  3348. æFp Appletalk.p
  3349. æT FUNCTION
  3350. æD FUNCTION PCloseSkt(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3351. æDT myVariable := PCloseSkt(thePBptr,async);
  3352. æRI CloseSkt function II-312,V513
  3353. æC CloseSkt function
  3354.  
  3355. Parameter block
  3356.  
  3357.     ->  26  csCode  word    ;always closeSkt
  3358.     ->  28  socket  byte    ;socket number
  3359.  
  3360. CloseSkt removes the entry of the specified socket from the socket table.  If you 
  3361. pass a socket number of 0, or if you attempt to close a socket that isn't open, 
  3362. CloseSkt will return ddpSktErr.
  3363.  
  3364. Result codes    
  3365.  
  3366.    noErr      No error
  3367.    ddpSktErr  Socket error
  3368.  
  3369. æKY PConfirmName
  3370. æFp Appletalk.p
  3371. æT FUNCTION
  3372. æD FUNCTION PConfirmName(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3373. æDT myVariable := PConfirmName(thePBptr,async);
  3374. æRI ConfirmName function II-323,V-513
  3375. æC ConfirmName function
  3376.  
  3377. Parameter block
  3378.  
  3379.     ->   26 csCode            word         ;always confirmName
  3380.     ->   28 interval          byte         ;retry interval
  3381.     <->  29  count            byte         ;retry count
  3382.     ->   30 entityPtr         pointer      ;pointer to entity name
  3383.     ->   34 confirmAddr       pointer      ;entity address
  3384.     <-   38 newSocket         byte         ;socket number
  3385.  
  3386. ConfirmName confirms that an entity known by name and address still exists (is 
  3387. still entered in the names directory).  EntityPtr points to the entity's name (in the 
  3388. form shown in Figure 13 above).  ConfirmAddr specifies the address to confirmed.  
  3389.  
  3390. No meta-characters are allowed in the entity name.  Interval and count contain the 
  3391. retry interval and the retry count.  The socket number of the entity is returned in 
  3392. newSocket.  ConfirmName is more efficient than LookupName in terms of network 
  3393. traffic.
  3394.  
  3395. Result codes    
  3396.  
  3397.    noErr           No error
  3398.    nbpConfDiff     Name confirmed for different socket
  3399.    nbpNoConfirm    Name not confirmed
  3400.  
  3401. æKY PDetachPH
  3402. æFp Appletalk.p
  3403. æT FUNCTION
  3404. æD FUNCTION PDetachPH(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3405. æDT myVariable := PDetachPH(thePBptr,async);
  3406. æRI DetachPH function  II-308, V-513
  3407.  
  3408. æC DetachPH function
  3409.  
  3410. Parameter block
  3411.     ->  26  csCode      word      ;always detachPH
  3412.     ->  28  protType    byte      ;ALAP protocol type
  3413.  
  3414. DetachPH removes from the node's protocol table the specified ALAP protocol type 
  3415. and corresponding protocol handler.
  3416.  
  3417. Result codes    
  3418.  
  3419.    noErr           No error
  3420.    lapProtErr      Error detaching protocol type
  3421.  
  3422. æKY PGetRequest
  3423. æFp Appletalk.p
  3424. æT FUNCTION
  3425. æD FUNCTION PGetRequest(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3426. æDT myVariable := PGetRequest(thePBPtr,async);
  3427. æRI GetRequest function II-317,V-513
  3428. æC GetRequest function
  3429.  
  3430. Parameter block
  3431.  
  3432.     <-   18 userData       long word   ;user bytes
  3433.     ->   26 csCode         word        ;always getRequest
  3434.     ->   28 atpSocket      byte        ;socket number
  3435.     <-   29 atpFlags       byte        ;control information
  3436.     <-   30 addrBlock      long word   ;source of request
  3437.     <->  34 reqLength      word        ;request buffer size
  3438.     ->   36 reqPointer     pointer     ;pointer to request buffer
  3439.     <-   44 bitMap         byte        ;bit map
  3440.     <-   46 transID        word        ;transaction ID
  3441.  
  3442. GetRequest sets up the mechanism to receive a request sent by a SendRequest call.  
  3443. UserData returns the four user bytes from the request.  ATPSocket contains the 
  3444. socket number of the socket that should listen for a request.  The internet address 
  3445. of the socket from which the request was sent is returned in addrBlock.  ReqLength 
  3446. and reqPointer indicate the size (in bytes) and location of a buffer to store the 
  3447. incoming request.  The actual size of the request is returned in reqLength.  The 
  3448. transaction bit map and transaction ID will be returned in bitMap and transID.  The 
  3449. exactly-once flag in atpFlags will be set if the request is part of an exactly-once 
  3450. transaction.
  3451.  
  3452. GetRequest completes when a request is received.
  3453.  
  3454. Result codes    
  3455.  
  3456.    noErr      No error
  3457.    badATPSkt  Bad responding socket
  3458.  
  3459. æKY PKillGetReq
  3460. æFp Appletalk.p
  3461. æT FUNCTION
  3462. æD FUNCTION PKillGetReq(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3463. æDT myVariable := PKillGetReq(thePBPtr,async);
  3464. æRI PKillGetReq function  V-518
  3465. æC  
  3466. »Aborting ATP GetRequests
  3467.  
  3468. ATP GetRequests can now be aborted through the PKillGetReq call.  This call looks and
  3469. works just like the PKillSendReq call, and is used to abort a specific GetRequest
  3470. call.  Previously it was necessary to close the socket  to abort all GetRequest calls
  3471. on the socket.
  3472.  
  3473. FUNCTION PKillGetReq (thePBptr: ATPPBPtr; async: BOOLEAN) : OSErr;
  3474.  
  3475. Parameter block
  3476.   -->    26    csCode    word     Always PKillGetReq
  3477.   -->    44    aKillQEl  pointer  Pointer to queue element
  3478.  
  3479. PKillGetReq will abort a specific outstanding GetRequest call (as opposed to closing
  3480. the socket, which aborts all outstanding GetRequests on that socket).  The call will
  3481. be completed with a reqAborted error.  To abort a GetRequest, place a pointer to the
  3482. queue element of the call to abort in aKillQEl and issue the PKillGetReq call.
  3483.  
  3484. Result Codes    noErr         No error
  3485.                 cbNotFound    aKillQEl does not point to a GetReq
  3486.                               queue element
  3487.  
  3488. æKY PKillNBP
  3489. æFp Appletalk.p
  3490. æT FUNCTION
  3491. æD FUNCTION PKillNBP(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3492. æDT myVariable := PKillNBP(thePBptr,async);
  3493. æRI PKillNBP function  V-518
  3494. æC  
  3495. _______________________________________________________________________________
  3496.  
  3497. »NAME BINDING PROTOCOL CHANGES
  3498. _______________________________________________________________________________
  3499.  
  3500. Changes to the Name Binding Protocol include supporting multiple concurrent requests
  3501. and a means for aborting an active request.
  3502.  
  3503. »Multiple Concurrent NBP Requests
  3504.  
  3505. NBP now supports multiple concurrent active requests.  Specifically, a number of
  3506. LookupNames, RegisterNames and ConfirmNames can all be active concurrently.  The
  3507. maximum number of  concurrent requests is machine dependent; if it is exceeded the
  3508. error tooManyReqs will be returned.  Active requests can be aborted by the PKillNBP
  3509. call.
  3510.  
  3511. »KillNBP function
  3512.  
  3513. FUNCTION PKillNBP (thePBptr: ATPPBPtr; async: BOOLEAN) : OSErr;
  3514.  
  3515. •••Refer to Technical Note #199:•••
  3516.  
  3517. Parameter block
  3518.   -->    26    csCode    word     Always PKillNBP
  3519.   -->    28    aKillQEl  pointer  Pointer to queue element
  3520.  
  3521. PKillNBP is used to abort an outstanding LookupName, RegisterName or ConfirmName
  3522. request.  To abort one of these calls, place a pointer to the queue element of the
  3523. call to abort in a KillQEl and issue the PKillNBP call.  The call will be completed
  3524. with a ReqAborted error.
  3525.  
  3526. Result Codes    noErr          No error
  3527.                 cbNotFound     aKillQEl does not point to a valid
  3528.                                NBP queue element
  3529.  
  3530. æKY PKillSendReq
  3531. æFp Appletalk.p
  3532. æT FUNCTION
  3533. æD FUNCTION PKillSendReq(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3534. æDT myVariable := PKillSendReq(thePBPtr,async);
  3535. æRI PKillSendReq function  V-517
  3536. æC  
  3537. »Aborting ATP SendRequests
  3538.  
  3539. The  RelTCB call is still supported, but only for aborting SendRequests.  To abort
  3540. PNSendRequests, a new call, PKillSendReq, has been added.  This call will abort both
  3541. SendRequests and PNSendRequests.  PKillSendReq’s only argument is the queue element
  3542. pointer of the request to be aborted.  The queue element pointer is passed at the
  3543. offset of the PKillSendReq queue element specified by aKillQE1.
  3544.  
  3545. FUNCTION PKillSendReq (thePBptr: ATPPBPtr; async: BOOLEAN) : OSErr;
  3546.  
  3547. Parameter block
  3548.   -->    26    csCode    word     Always PKillSendReq
  3549.   -->    44    aKillQEl  pointer  Pointer to queue element
  3550.  
  3551. PKillSendReq is functionally equivalent to RelTCB, except that it takes different
  3552. arguments and will abort both SendRequests and PNSendRequests.  To abort one of these
  3553. calls, place a pointer to the queue element of the call to abort in aKillQEl and
  3554. issue the PKillSendReq call.
  3555.  
  3556. Result Codes    noErr          No error
  3557.                 cbNotFound     aKillQEl does not point to a SendReq
  3558.                                or NSendReq queue element
  3559.  
  3560. æKY PLookupName
  3561. æFp Appletalk.p
  3562. æT FUNCTION
  3563. æD FUNCTION PLookupName(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3564. æDT myVariable := PLookupName(thePBptr,async);
  3565. æRI LookupName function II-323,V-513
  3566. æC LookupName function
  3567.  
  3568. Parameter block
  3569.  
  3570.     ->   26 csCode        word      ;always lookupName
  3571.     ->   28 interval      byte      ;retry interval
  3572.     <->  29 count         byte      ;retry count
  3573.     ->   30 entityPtr     pointer   ;pointer to entity name
  3574.     ->   34 retBuffPtr    pointer   ;pointer to buffer
  3575.     ->   38 retBuffSize   word      ;buffer size in bytes
  3576.     ->   40 maxToGet      word      ;matches to get
  3577.     <->  42 numGotten     word      ;matches found 
  3578.  
  3579. LookupName returns the addresses of all entities with a specified name.  EntityPtr 
  3580. points to the entity's name (in the form shown in Figure 13 above).  Meta-
  3581. characters are allowed in the entity name.  RetBuffPtr and retBuffSize contain the 
  3582. location and size of an area of memory in which the tuples describing the entity 
  3583. names and their corresponding addresses should be returned.  MaxToGet indicates 
  3584. the maximum number of matching names to find addresses for; the actual number of 
  3585. addresses found is returned in numGotten.  Interval and count contain the retry 
  3586. interval and the retry count.  LookupName completes when either the number of 
  3587. matches is equal to or greater than maxToGet, or the retry count has been exceeded.  
  3588. The count field is decremented for each retransmission.
  3589.  
  3590. Note:  NumGotten is first set to 0 and then incremented with each match 
  3591.        found.  You can test the value in this field, and can start examining the 
  3592.        received addresses in the buffer while the lookup continues.
  3593.  
  3594. Result codes    
  3595.  
  3596.    noErr           No error
  3597.    nbpBuffOvr      Buffer overflow
  3598.  
  3599. æKY PNSendRequest
  3600. æFp Appletalk.p
  3601. æT FUNCTION
  3602. æD FUNCTION PNSendRequest(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3603. æDT myVariable := PNSendRequest(thePBPtr,async);
  3604. æRI PNSendRequest function  V-516
  3605. æC  
  3606. »Sending an ATP Request Through a Specified Socket
  3607.  
  3608. ATP requests can now be sent through client-specified sockets.  ATP previously would
  3609. open a dynamic socket, send the request through it, and close the socket when the
  3610. request was completed.  The client can now choose to send a request through an already-opened
  3611. socket; this also allows more than one request to be sent per socket.   A new call,
  3612. PNSendRequest, has been added for this purpose.  The function of the old SendRequest
  3613. call itself remains unchanged.
  3614.  
  3615. FUNCTION PNSendRequest (thePBptr: ATPBPtr; async: BOOLEAN) : OSErr;
  3616.  
  3617. Parameter block
  3618.   -->    18    userData     longword  User bytes
  3619.   <--    22    reqTID       word      Transaction ID used in request
  3620.   -->    26    csCode       word      Always sendRequest
  3621.   <->    28    atpSocket    byte      Socket to send request on
  3622.                                        or current bitmap
  3623.   <->    29    atpFlags     byte      Control information
  3624.   -->    30    addrBlock    longword  Destination socket address
  3625.   -->    34    reqLength    word      Request size in bytes
  3626.   -->    36    reqPointer   pointer   Pointer to request data
  3627.   -->    40    bdsPointer   pointer   Pointer to response BDS
  3628.   -->    44    numOfBuffs   byte      Number of responses expected
  3629.   -->    45    timeOutVal   byte      Timeout interval
  3630.   <--    46    numOf Resps  byte      Number of responses received
  3631.   <->    47    retryCount   byte      Number of retries
  3632.   <--    48    intBuff      word      Used internally
  3633.  
  3634. The PNSendRequest call is functionally equivalent to the SendRequest call, however
  3635. PNSendRequest allows you to specify, in the atpSocket field, the socket through which
  3636. the request is to be sent.  This socket must have been previously opened through an
  3637. OpenATPSkt request (otherwise a badATPSkt error will be returned).  Note that PNSendRequest
  3638. requires two additional bytes of memory at the end of the parameter block, immediately
  3639. following the retryCount.  These bytes are for the internal use of the AppleTalk
  3640. Manager and should not be modified while the PNSendRequest call is active.
  3641.  
  3642. There is a machine-dependent limit as to the number of concurrent PNSendRequests that
  3643. can be active on a given socket.  If this limit is exceeded, the error tooManyReqs is
  3644. returned.
  3645.  
  3646. One additional difference between SendRequest and PNSendRequest is that a PNSendRequest
  3647. can only be aborted by a PKillSendReq call (see below), whereas a SendRequest can be
  3648. aborted by either a RelTCB or KillSendReq call.
  3649.  
  3650. Result Codes    noErr          No error
  3651.                 reqFailed      Retry count exceeded
  3652.                 tooManyReqs    Too many concurrent requests
  3653.                 noDataArea     Too many outstanding ATP calls
  3654.                 reqAborted     Request cancelled by user
  3655.  
  3656. æKY POpenATPSkt
  3657. æFp Appletalk.p
  3658. æT FUNCTION
  3659. æD FUNCTION POpenATPSkt(thePBptr: ATPPBPtr;async: BOOLEAN): OSErr;
  3660. æDT myVariable := POpenATPSkt(thePBptr,async);
  3661. æRI OpenATPSkt function II-315,V-513
  3662. æC OpenATPSkt function
  3663.  
  3664. Parameter block
  3665.  
  3666.     ->  26 csCode        word         ;always openATPSkt
  3667.     <-> 28  atpSocket    byte         ;socket number
  3668.     ->  30  addrBlock    long word    ;socket request specification
  3669.  
  3670. OpenATPSkt opens a socket for the purpose of receiving requests.  ATPSocket 
  3671. contains the socket number of the socket to open.  If it's 0, a number is dynamically 
  3672. assigned and returned in atpSocket.  AddrBlock contains a specification of the 
  3673. socket addresses from which requests will be accepted.  A 0 in the network number, 
  3674. node ID, or socket number field of addrBlock means that requests will be accepted 
  3675. from every network, node, or socket, respectively.
  3676.  
  3677. Result codes    
  3678.  
  3679.    noErr             No error
  3680.    tooManySkts       Too many responding sockets
  3681.    noDataArea        Too many outstanding ATP calls
  3682.  
  3683. æKY POpenSkt
  3684. æFp Appletalk.p
  3685. æT FUNCTION
  3686. æD FUNCTION POpenSkt(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3687. æDT myVariable := POpenSkt(thePBptr,async);
  3688. æRI OpenSkt function II-311, V-513
  3689.  
  3690. æC OpenSkt function
  3691.  
  3692. Parameter block
  3693.  
  3694.     ->  26  csCode      word         ;always openSkt
  3695.     <-> 28  socket      byte         ;socket number
  3696.     ->  30  listener    pointer      ;socket listener
  3697.  
  3698. OpenSkt adds a socket and its socket listener to the socket table.  If the socket 
  3699. parameter is nonzero, it must be in the range 64 to 127, and it specifies the 
  3700. socket's number; if socket is 0, OpenSkt opens a socket with a socket number in the 
  3701. range 128 to 254, and returns it in the socket parameter.  Listener contains a 
  3702. pointer to the socket listener.
  3703.  
  3704. OpenSkt will return ddpSktErr if you pass the number of an already opened socket, 
  3705. if you pass a socket number greater than 127, or if the socket table is full (the 
  3706. socket table can hold a maximum of 12 sockets).
  3707.  
  3708. Result codes    
  3709.  
  3710.    noErr         No error
  3711.    ddpSktErr     Socket error
  3712.  
  3713. æKY PRegisterName
  3714. æFp Appletalk.p
  3715. æT FUNCTION
  3716. æD FUNCTION PRegisterName(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3717. æDT myVariable := PRegisterName(thePBptr,async);
  3718. æRI RegisterName function II-322,V-513
  3719. æC RegisterName function
  3720.  
  3721. Parameter block
  3722.  
  3723.     ->  26  csCode         word          ;always registerName
  3724.     ->  28  interval       byte          ;retry interval
  3725.     <-> 29  count          byte          ;retry count
  3726.     ->  30  ntQElPtr       pointer       ;names table element pointer 
  3727.     ->  34  verifyFlag     byte          ;set if verify needed 
  3728.  
  3729. RegisterName adds the name and address of an entity to the node's names table.  
  3730. NTQElPtr points to a names table entry containing the entity's name and internet 
  3731. address (in the form shown in Figure 13 above).  Meta-characters aren't allowed in 
  3732. the object and type fields of the entity name; the zone field, however, must contain 
  3733. the meta-character "*".  If verifyFlag is TRUE, RegisterName checks on the network 
  3734. to see if the name is already in use, and returns a result code of nbpDuplicate 
  3735. if so.  
  3736.  
  3737. Interval and count contain the retry interval in eight-tick units and the 
  3738. retry count.  
  3739. When a retry is made, the count field is modified.
  3740.  
  3741. Warning:  The names table entry passed to RegisterName remains the 
  3742.           property of NBP until removed from the names table.  Don't attempt to remove 
  3743.           or modify it.  If you've allocated memory using a NewHandle call, you must 
  3744.           lock it as long as the name is registered. 
  3745.  
  3746. Warning:  VerifyFlag should normally be set before calling RegisterName.
  3747.  
  3748. Result codes    
  3749.  
  3750.    noErr          No error
  3751.    nbpDuplicate   Duplicate name already exists
  3752.    nbpNISErr      Error opening names information socket 
  3753.  
  3754. æKY PRelRspCB
  3755. æFp Appletalk.p
  3756. æT FUNCTION
  3757. æD FUNCTION PRelRspCB(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3758. æDT myVariable := PRelRspCB(thePBPtr,async);
  3759. æRI RelRspCB function II-319,V-514
  3760. æC RelRspCB function
  3761.  
  3762. Parameter block
  3763.  
  3764.     ->  26  csCode        word        ;always relRspCB
  3765.     ->  28  atpSocket     byte        ;socket number that request was received on
  3766.     ->  30  addrBlock     long word   ;source of request
  3767.     ->  46  transID       word        ;transaction ID of request
  3768.  
  3769. In an exactly-once transaction, RelRspCB cancels the specified SendResponse, 
  3770. without waiting for the release timer to expire or a TRel packet to be received.  No 
  3771. error is returned for the SendResponse call.  Whan called to cancel a transaction 
  3772. that isn't using exactly-once service, RelRspCB returns cbNotFound.  The 
  3773. transaction ID can be obtained from the reqTID field of the SendResponse queue 
  3774. entry; see the description of SendResponse for details.
  3775.  
  3776. Result codes    
  3777.  
  3778.    noErr            No error
  3779.    cbNotFound       ATP control block not found
  3780.  
  3781. æKY PRelTCB
  3782. æFp Appletalk.p
  3783. æT FUNCTION
  3784. æD FUNCTION PRelTCB(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3785. æDT myVariable := PRelTCB(thePBPtr,async);
  3786. æRI RelTCB function II-319,V-513
  3787. æC RelTCB function
  3788.  
  3789. Parameter block
  3790.  
  3791.     ->  26  csCode        word          ;always relTCB
  3792.     ->  30  addrBlock     long word     ;destination of request
  3793.     ->  46  transID       word          ;transaction ID of request
  3794.  
  3795. RelTCB dequeues the specified SendRequest call and returns the result code 
  3796. reqAborted for the aborted call.  The transaction ID can be obtained from the reqTID 
  3797. field of the SendRequest queue entry; see the description of SendRequest for details.
  3798.  
  3799. Result codes    
  3800.  
  3801.    noErr            No error
  3802.    cbNotFound       ATP control block not found
  3803.    noDataArea       Too many outstanding ATP calls
  3804.  
  3805. æKY PRemoveName
  3806. æFp Appletalk.p
  3807. æT FUNCTION
  3808. æD FUNCTION PRemoveName(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3809. æDT myVariable := PRemoveName(thePBptr,async);
  3810. æRI RemoveName function II-324,V-513
  3811. æC RemoveName function
  3812.  
  3813. Parameter block
  3814.  
  3815.     ->  26  csCode       word        ;always removeName 
  3816.     ->  30  entityPtr    pointer     ;pointer to entity name 
  3817.  
  3818. RemoveName removes an entity name from the names table of the given entity's node.
  3819.  
  3820. Result codes    
  3821.  
  3822.    noErr            No error
  3823.    nbpNotFound      Name not found 
  3824.  
  3825. æKY PSendRequest
  3826. æFp Appletalk.p
  3827. æT FUNCTION
  3828. æD FUNCTION PSendRequest(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3829. æDT myVariable := PSendRequest(thePBPtr,async);
  3830. æRI SendRequest function II-316,V-513
  3831. æC SendRequest function
  3832.  
  3833. Parameter block
  3834.  
  3835.     ->   18 userData         long word      ;user bytes
  3836.     <-   22 reqTID           word           ;transaction ID used in request
  3837.     ->   26 csCode           word           ;always sendRequest
  3838.     <-   28 currBitMap       byte           ;bit map
  3839.     <->  29 atpFlags         byte           ;control information
  3840.     ->   30 addrBlock        long word      ;destination socket address
  3841.     ->   34 reqLength        word           ;request size in bytes
  3842.     ->   36 reqPointer       pointer        ;pointer to request data
  3843.     ->   40 bdsPointer       pointer        ;pointer to response BDS
  3844.     ->   44 numOfBuffs       byte           ;number of responses expected
  3845.     ->   45 timeOutVal       byte           ;timeout interval
  3846.     <-   46 numOfResps       byte           ;number of responses received
  3847.     <->  47 retryCount       byte           ;number of retries
  3848.  
  3849. SendRequest sends a request to another socket and waits for a response.  UserData 
  3850. contains the four user bytes.  AddrBlock indicates the socket to which the request 
  3851. should be sent.  ReqLength and reqPointer contain the size and location of the 
  3852. request to send.  BDSPointer points to a response BDS where the responses are to be 
  3853. returned; numOfBuffs indicates the number of responses requested.  The number of 
  3854. responses received is returned in numOfResps.  If a nonzero value is returned in 
  3855. numOfResps, you can examine currBitMap to determine which packets of the 
  3856. transaction were actually received and to detect pieces for higher-level recovery, 
  3857. if desired.
  3858.  
  3859. TimeOutVal indicates the number of seconds that SendRequest should wait for a 
  3860. response before resending the request.  RetryCount indicates the maximum number 
  3861. of retries SendRequest should attempt.  The end-of-message flag of atpFlags will 
  3862. be set if the EOM bit is set in the last packet received in a valid response
  3863. sequence.  
  3864. The exactly-once flag should be set if you want the request to be part of an 
  3865. exactly-once transaction.
  3866.  
  3867. To cancel a SendRequest call, you need the transaction ID; it's returned in reqTID.  
  3868. You can examine reqTID before the completion of the call, but its contents are valid 
  3869. only after the tidValid bit of atpFlags has been set.
  3870. SendRequest completes when either an entire response is received or the retry 
  3871. count is exceeded.
  3872.  
  3873. Note:  The value provided in retryCount will be modified during SendRequest 
  3874.        if any retries are made.  This field is used to monitor the number of retries; 
  3875.        for each retry, it's decremented by 1.
  3876.  
  3877. Result codes    
  3878.  
  3879.    noErr             No error
  3880.       reqFailed      Retry count exceeded
  3881.       tooManyReqs      Too many concurrent requests
  3882.       noDataArea        Too many outstanding ATP calls
  3883.       reqAborted        Request canceled by user
  3884.  
  3885. æKY PSendResponse
  3886. æFp Appletalk.p
  3887. æT FUNCTION
  3888. æD FUNCTION PSendResponse(thePBPtr: ATPPBPtr;async: BOOLEAN): OSErr;
  3889. æDT myVariable := PSendResponse(thePBPtr,async);
  3890. æRI SendResponse function II-317,V-513
  3891. æC SendResponse function
  3892.  
  3893. Parameter block
  3894.  
  3895.     <-  18  userData      long word     ;user bytes from TRel
  3896.     <-  22  reqTID        word          ;transaction ID used in request
  3897.     ->  26  csCode        word          ;always sendResponse
  3898.     ->  28  atpSocket     byte          ;socket number
  3899.     ->  29  atpFlags      byte          ;control information
  3900.     ->  30  addrBlock     long word     ;response destination
  3901.     ->  40  bdsPointer    pointer       ;pointer to response BDS 
  3902.     ->  44  numOfBuffs    byte          ;number of response packets being sent
  3903.     ->  45  bdsSize       byte          ;BDS size in elements
  3904.     ->  46  transID       word          ;transaction ID 
  3905.  
  3906. SendResponse sends a response to a socket.  If the response was part of an exactly-
  3907. once transaction, userData will contain the user bytes from the TRel packet.  
  3908. ATPSocket contains the socket number from which the response should be sent.  The 
  3909. end-of-message flag in atpFlags should be set if the response contains the final 
  3910. packet in a transaction composed of a group of packets and the number of responses 
  3911. is less than requested.  AddrBlock indicates the address of the socket to which the 
  3912. response should be sent.  BDSPointer points to a response BDS containing room for 
  3913. the maximum number of responses to be sent; bdsSize contains this maximum 
  3914. number.  NumOfBuffs contains the number of response packets to be sent in this 
  3915. call; you may wish to make AddResponse calls to complete the response.  TransID 
  3916. indicates the transaction ID of the associated request.
  3917.  
  3918. During exactly-once transactions, SendResponse doesn't complete until either a 
  3919. TRel packet is received from the socket that made the request, or the retry count is 
  3920. exceeded.
  3921.  
  3922. Result codes    
  3923.  
  3924.       noErr              No error
  3925.       badATPSkt          Bad responding socket
  3926.       noRelErr           No release received
  3927.       noDataArea         Too many outstanding ATP calls
  3928.       badBuffNum         Sequence number out of range
  3929.  
  3930. æKY PSetSelfSend
  3931. æFp Appletalk.p
  3932. æT FUNCTION
  3933. æD FUNCTION PSetSelfSend(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3934. æDT myVariable := PSetSelfSend(thePBptr,async);
  3935. æRI PSetSelfSend function  V-516
  3936. æC  
  3937. _______________________________________________________________________________
  3938.  
  3939. »SENDING PACKETS TO ONE’S OWN NODE
  3940. _______________________________________________________________________________
  3941.  
  3942. Upon opening, the ability to send a packet to one’s own node (intranode delivery) is
  3943. disabled.  This feature of the AppleTalk Manager can be manipulated through the
  3944. SetSelfSend function.  Once enabled, it is possible, at all levels, to send packets
  3945. to entities within one’s own node.  An example of where this might be desirable is an
  3946. application sending data to a print spooler that is actually running in the background
  3947. on the same node.
  3948.  
  3949. Enabling (or disabling) this feature affects the entire node and should be performed
  3950. with care.  For instance, a desk accessory may not expect to receive names from
  3951. within its own node as a response to an NBP look-up;  enabling this feature from an
  3952. application could break the desk accessory.  All future programs should be written
  3953. with this feature in mind.
  3954.  
  3955. FUNCTION PSetSelfSend (thePBptr: MPPPBPtr; async: BOOLEAN) : OSErr;
  3956.  
  3957. Parameter Block
  3958.   -->    26    csCode         word    Always PSetSelfSend
  3959.   -->    28    newSelfFlag    byte    New SelfSend flag
  3960.   <--    29    oldSelfFlag    byte    Old SelfSend flag
  3961.  
  3962. PSetSelfSend enables or disables the intranode delivery feature of the AppleTalk
  3963. Manager.  If newSelfFlag is nonzero, the feature will be enabled; otherwise it will
  3964. be disabled.  The previous value of the flag will be returned in oldSelfFlag.
  3965.  
  3966. Result Codes    noErr        No error
  3967.  
  3968. æKY PWriteDDP
  3969. æFp Appletalk.p
  3970. æT FUNCTION
  3971. æD FUNCTION PWriteDDP(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3972. æDT myVariable := PWriteDDP(thePBptr,async);
  3973. æRI WriteDDP function II-312,V-513
  3974. æC WriteDDP function
  3975.  
  3976. Parameter block
  3977.  
  3978.     ->  26  csCode            word        ;always writeDDP
  3979.     ->  28  socket            byte        ;socket number
  3980.     ->  29  checksumFlag      byte        ;checksum flag
  3981.     ->  30  wdsPointer        pointer     ;write data structure
  3982.  
  3983. WriteDDP sends a datagram to another socket.  WDSPointer points to a write data 
  3984. structure containing the datagram and the address of the destination socket.  If 
  3985. checksumFlag is TRUE, WriteDDP will compute the checksum for all datagrams 
  3986. requiring long headers.
  3987.  
  3988. Result codes    
  3989.  
  3990.       noErr          No error
  3991.       ddpLenErr      Datagram length too big
  3992.       ddpSktErr      Socket error
  3993.       noBridgeErr    No bridge found 
  3994.  
  3995. æKY PWriteLAP
  3996. æFp Appletalk.p
  3997. æT FUNCTION
  3998. æD FUNCTION PWriteLAP(thePBptr: MPPPBPtr;async: BOOLEAN): OSErr;
  3999. æDT myVariable := PWriteLAP(thePBptr,async);
  4000. æRI WriteLAP function II-307, V-513
  4001.  
  4002. æC WriteLAP function
  4003.  
  4004. Parameter block
  4005.  
  4006.     ->  26  csCode          word       ;always writeLAP
  4007.     ->  30  wdsPointer      pointer    ;write data structure
  4008.  
  4009. WriteLAP sends a frame to another node.  The frame data and destination of the 
  4010. frame are described by the write data structure pointed to by wdsPointer.  The 
  4011. first two data bytes of an ALAP frame sent to another computer using the 
  4012. AppleTalk Manager must indicate the length of the frame in bytes.  The ALAP 
  4013. protocol type byte must be in the range 1 to 127.
  4014.  
  4015. Result codes    
  4016.  
  4017.       noErr          No error
  4018.       excessCollsns  No CTS received after 32 RTS's
  4019.       ddpLengthErr   Packet length exceeds maximum
  4020.       lapProtErr     Invalid ALAP protocol type
  4021.  
  4022. æKY RemoveHdlBlocks
  4023. æFp Appletalk.p
  4024. æT PROCEDURE
  4025. æD PROCEDURE RemoveHdlBlocks;
  4026. æDT RemoveHdlBlocks;
  4027.  
  4028. æKY RetransType
  4029. æFp AppleTalk.p
  4030. æT PACKED RECORD
  4031. æC RetransType = PACKED RECORD
  4032.    retransInterval: Byte;
  4033.    retransCount: Byte;
  4034.    END;
  4035.  
  4036. æKY scbMemSize
  4037. æFp Appletalk.p
  4038. æC scbMemSize = 192; {Size of memory for SCB }
  4039.  
  4040. æKY Str32
  4041. æFp AppleTalk.p
  4042. æT TYPE
  4043. æC Str32 = String[32];
  4044.  
  4045. æKY WDSElement
  4046. æFp AppleTalk.p
  4047. æT RECORD
  4048. æC WDSElement = RECORD
  4049.    entryLength: INTEGER;
  4050.    entryPtr: Ptr;
  4051.    END;
  4052.  
  4053. æKY xppFlagClr
  4054. æFp Appletalk.p
  4055. æC xppFlagClr = 0; {Cs for AFPCommandBlock }
  4056.  
  4057. æKY xppFlagSet
  4058. æFp Appletalk.p
  4059. æC xppFlagSet = 128; {StartEndFlag & NewLineFlag fields. }
  4060.  
  4061. æKY xppLoadedBit
  4062. æFp Appletalk.p
  4063. æC xppLoadedBit = 5; { XPP bit in PortBUse }
  4064.  
  4065. æKY xppRefNum
  4066. æFp Appletalk.p
  4067. æC xppRefNum = -41; {.XPP reference number }
  4068.  
  4069. æKY xppUnitNum
  4070. æFp Appletalk.p
  4071. æC xppUnitNum = 40; {Unit number for XPP (old ROMs) }
  4072.  
  4073.  
  4074. æKY Controls.p
  4075. æKL DisposeControl
  4076. DragControl
  4077. Draw1Control
  4078. DrawControls
  4079. FindControl
  4080. GetAuxCtl
  4081. GetCRefCon
  4082. GetCTitle
  4083. GetCtlAction
  4084. GetCtlMax
  4085. GetCtlMin
  4086. GetCtlValue
  4087. GetCVariant
  4088. GetNewControl
  4089. HideControl
  4090. HiliteControl
  4091. KillControls
  4092. MoveControl
  4093. NewControl
  4094. SetCRefCon
  4095. SetCTitle
  4096. SetCtlAction
  4097. SetCtlColor
  4098. SetCtlMax
  4099. SetCtlMin
  4100. SetCtlValue
  4101. ShowControl
  4102. SizeControl
  4103. TestControl
  4104. TrackControl
  4105. UpdtControl
  4106.  
  4107. autoTrack
  4108. AuxCtlHandle
  4109. AuxCtlPtr
  4110. AuxCtlRec
  4111. calcCRgns
  4112. cBodyColor
  4113. CColorTable
  4114. CCTabHandle
  4115. CCTabPtr
  4116. cFrameColor
  4117. checkBoxProc
  4118. ColorTable
  4119. ControlHandle
  4120. ControlPtr
  4121. ControlRecord
  4122. CTabHandle
  4123. CTabPtr
  4124. cTextColor
  4125. cThumbColor
  4126. dispCntl
  4127. dragCntl
  4128. drawCntl
  4129. hAxisOnly
  4130. inButton
  4131. inCheckBox
  4132. inDownButton
  4133. initCntl
  4134. inPageDown
  4135. inPageUp
  4136. inThumb
  4137. inUpButton
  4138. noConstraint
  4139. posCntl
  4140. pushButProc
  4141. radioButProc
  4142. scrollBarProc
  4143. testCntl
  4144. thumbCntl
  4145. useWFont
  4146. vAxisOnly
  4147.  
  4148. æKY AuxCtlRec,AuxCtlPtr,AuxCtlHandle
  4149. æFp Controls.p
  4150. æT TYPE
  4151. æC AuxCtlPtr = ^AuxCtlRec;
  4152. AuxCtlHandle = ^AuxCtlPtr;
  4153. AuxCtlRec = RECORD
  4154.    acNext: AuxCtlHandle;       {handle to next AuxCtlRec}
  4155.    acOwner: ControlHandle;     {handle for aux record's control}
  4156.    acCTable: CCTabHandle;      {color table for this control}
  4157.    acFlags: INTEGER;           {misc flag byte}
  4158.    acReserved: LONGINT;        {reserved for use by Apple}
  4159.    acRefCon: LONGINT;          {for use by application}
  4160.    END;
  4161.  
  4162. The information needed for drawing controls in color is kept in a linked list of
  4163. auxiliary control records, beginning in the global variable AuxCtlHead.
  4164. (Notice that there is just one global list for all controls in all windows, not a
  4165. separate one for each window.) Each window record has a handle to the list of controls.
  4166. Figure 5 shows the auxiliary control list structure.
  4167.  
  4168. •••Refer to Figure 5.•••
  4169.  
  4170. Figure 5–Auxiliary Control List
  4171.  
  4172. Each auxiliary control record is a relocatable object residing in the application
  4173. heap. The most important information it holds is a handle to the control’s individual
  4174. color table (see the “Control Color Tables” section).  The rest of the record consists
  4175. of a link to the next record in the list, a field that identifies the control’s
  4176. owner, a 4-byte field reserved for future expansion, and a 4-byte reference constant
  4177. for use by the application:
  4178.  
  4179. TYPE
  4180.   AuxCtlHandle = ^AuxCtlPtr;
  4181.   AuxCtlPtr    = ^AuxCtlRec;
  4182.   AuxCtlRec    = RECORD
  4183.                    acNext:      AuxCtlHandle;   {handle to next record in list}
  4184.                    acOwner:     ControlHandle;  {handle to owning control}
  4185.                    acCTable:    CCTabHandle;    {handle to control's color }
  4186.                                                 { table}
  4187.                    acFlags:     INTEGER;        {miscellaneous flags; reserved}
  4188.                    acReserved:  LONGINT;        {reserved for future expansion}
  4189.                    acRefCon:    LONGINT         {reserved for application use}
  4190.                  END;
  4191.  
  4192. Field descriptions
  4193.  
  4194. acNext        The acNext field contains a handle to the next record in
  4195.               the auxiliary control list.
  4196.  
  4197. acOwner       The acOwner field contains the handle of the control to
  4198.               which this auxiliary record belongs. Used as an ID field.
  4199.  
  4200. acCTable      The acCTable contains the handle to the control’s color
  4201.               table (see “Control Color Tables” below).
  4202.  
  4203. acFlags       The acFlags field contains miscellaneous flags for use by
  4204.               the Control Manager; this field is reserved.
  4205.  
  4206. acReserved    The acReserved field is reserved for future expansion;
  4207.               this must be set to 0 for future compatibility.
  4208.  
  4209. acRefCon      The acRefCon field is a reference constant for use by
  4210.               the application.
  4211.  
  4212. Not every control needs an auxiliary control record.  When an application is started,
  4213. a resource containing a default color table is loaded from the system resource file;
  4214. this resource defines a standard set of control colors. Since there is no InitControls
  4215. routine, this happens when an application calls InitWindows.
  4216.  
  4217. Separate auxiliary control records are needed only for controls whose color usage
  4218. differs from the default.  Each such nonstandard control must have its own auxiliary
  4219. record, even if it uses the same colors as another control. This allows two or more
  4220. auxiliary records to share the same control color table. If the control color table
  4221. is a resource, it won’t be deleted by DisposeControl. When using an auxiliary record
  4222. that is not stored as a resource, the application should not deallocate the color
  4223. table if another control is still using it.
  4224.  
  4225. A control created from scratch will initially have no auxiliary control record.  If
  4226. it is to use nonstandard colors, it must be given an auxiliary record and a color
  4227. table with SetCtlColor (see the “Control Manager Routines” section).  Such a control
  4228. should normally be made invisible at creation and then displayed with ShowControl
  4229. after the colors are set.  For controls created from a 'CNTL' resource,  the color
  4230. table can be specified as a resource as well. See the section titled “The Control
  4231. Color Table Resource”.
  4232.  
  4233. A/UX systems:  When using 32-bit mode. every control has its own auxiliary
  4234.                record. If there is no specific set of control colors for
  4235.                this control, the acCTable will point to the default color table.
  4236.  
  4237. æKY cFrameColor,cBodyColor,cTextColor,cThumbColor
  4238. æFp Controls.p
  4239. æC 
  4240.   { Control part colors }
  4241.  
  4242.   cFrameColor  =  0;
  4243.   cBodyColor   =  1;
  4244.   cTextColor   =  2;
  4245.   cThumbColor  =  3;
  4246.  
  4247. æKY ControlRecord,ControlPtr,ControlHandle
  4248. æFp Controls.p
  4249. æT TYPE
  4250. æC ControlPtr = ^ControlRecord;
  4251. ControlHandle = ^ControlPtr;
  4252. ControlRecord = PACKED RECORD
  4253.    nextControl: ControlHandle;
  4254.    contrlOwner: WindowPtr;
  4255.    contrlRect: Rect;
  4256.    contrlVis: Byte;
  4257.    contrlHilite: Byte;
  4258.    contrlValue: INTEGER;
  4259.    contrlMin: INTEGER;
  4260.    contrlMax: INTEGER;
  4261.    contrlDefProc: Handle;
  4262.    contrlData: Handle;
  4263.    contrlAction: ProcPtr;
  4264.    contrlRfCon: LONGINT;
  4265.    contrlTitle: Str255;
  4266.    END;
  4267.  
  4268. Every control is represented internally by a control record containing all pertinent
  4269. information about that control. The control record contains the following:
  4270.  
  4271.   •  A pointer to the window the control belongs to.
  4272.   •  A handle to the next control in the window’s control list.
  4273.   •  A handle to the control definition function.
  4274.   •  The control’s title, if any.
  4275.   •  A rectangle that completely encloses the control, which determines
  4276.      the control’s size and location within its window. The entire control,
  4277.      including the title of a check box or radio button, is drawn inside
  4278.      this rectangle.
  4279.   •  An indication of whether the control is currently active and how it’s
  4280.      to be highlighted.
  4281.   •  The current setting of the control (if this type of control retains a
  4282.      setting) and the minimum and maximum values the setting can assume. For
  4283.      check boxes and radio buttons, a setting of 0 means the control is off
  4284.      and 1 means it’s on.
  4285.  
  4286. The control record also contains an indication of whether the control is currently
  4287. visible or invisible. These terms refer only to whether the control is drawn in its
  4288. window, not to whether you can see it on the screen. A control may be “visible” and
  4289. still not appear on the screen, because it’s obscured by overlapping windows or other
  4290. objects.
  4291.  
  4292. There’s a field in the control record for a pointer to the control’s default action
  4293. procedure. An action procedure defines some action to be performed repeatedly for as
  4294. long as the user holds down the mouse button inside the control. The default action
  4295. procedure may be used by the Control Manager function TrackControl if you call it
  4296. without passing a pointer to an action procedure; this is discussed in detail in the
  4297. description of TrackControl in the “Control Manager Routines” section.
  4298.  
  4299. Finally, the control record includes a 32-bit reference value field, which is reserved
  4300. for use by your application. You specify an initial reference value when you create a
  4301. control, and can then read or change the reference value whenever you wish.
  4302.  
  4303. The data type for a control record is called ControlRecord. A control record is
  4304. referred to by a handle:
  4305.  
  4306. TYPE  ControlPtr     = ^ControlRecord;
  4307.       ControlHandle  = ^ControlPtr;
  4308.  
  4309. The Control Manager functions for creating a control return a handle to a newly
  4310. allocated control record; thereafter, your program should normally refer to the
  4311. control by this handle. Most of the Control Manager routines expect a control handle
  4312. as their first parameter.
  4313.  
  4314. You can store into and access most of a control record’s fields with Control Manager
  4315. routines, so normally you don’t have to know the exact field names. However, if you
  4316. want more information about the exact structure of a control record—if you’re defining
  4317. your own control types, for instance—it’s given below.
  4318.  
  4319. _______________________________________________________________________________
  4320.  
  4321. »The ControlRecord Data Type
  4322.  
  4323. The ControlRecord data type is defined as follows:
  4324.  
  4325. TYPE ControlRecord =
  4326.       PACKED RECORD
  4327.         nextControl:    ControlHandle;  {next control}
  4328.         contrlOwner:    WindowPtr;      {control's window}
  4329.         contrlRect:     Rect;           {enclosing rectangle}
  4330.         contrlVis:      Byte;           {255 if visible}
  4331.         contrlHilite:   Byte;           {highlight state}
  4332.         contrlValue:    INTEGER;        {control's current setting}
  4333.         contrlMin:      INTEGER;        {control's minimum setting}
  4334.         contrlMax:      INTEGER;        {control's maximum setting}
  4335.         contrlDefProc:  Handle;         {control definition function}
  4336.         contrlData:     Handle;         {data used by contrlDefProc}
  4337.         contrlAction:   ProcPtr;        {default action procedure}
  4338.         contrlRfCon:    LONGINT;        {control's reference value}
  4339.         contrlTitle:    Str255          {control's title}
  4340.       END;
  4341.  
  4342. NextControl is a handle to the next control associated with this control’s window.
  4343. All the controls belonging to a given window are kept in a linked list, beginning in
  4344. the controlList field of the window record and chained together through the nextControl
  4345. fields of the individual control records. The end of the list is marked by a NIL
  4346. value; as new controls are created, they’re added to the beginning of the list.
  4347.  
  4348. ContrlOwner is a pointer to the window that this control belongs to.
  4349.  
  4350. ContrlRect is the rectangle that completely encloses the control, in the local coordinates
  4351. of the control’s window.
  4352.  
  4353. When contrlVis is 0, the control is currently invisible; when it’s 255, the control
  4354. is visible.
  4355.  
  4356. ContrlHilite specifies whether and how the control is to be highlighted, indicating
  4357. whether it’s active or inactive. The HiliteControl procedure lets you set this field;
  4358. see the description of HiliteControl for more information about the meaning of the
  4359. field’s value.
  4360.  
  4361. ContrlValue is the control’s current setting. For check boxes and radio buttons, 0
  4362. means the control is off and 1 means it’s on. For dials, the fields contrlMin and
  4363. contrlMax define the range of possible settings; contrlValue may take on any value
  4364. within that range. Other (custom) control types can use these three fields as they
  4365. see fit.
  4366.  
  4367. ContrlDefProc is a handle to the control definition function for this type of control.
  4368. When you create a control, you identify its type with a control definition ID, which
  4369. is converted into a handle to the control definition function and stored in the
  4370. contrlDefProc field. Thereafter, the Control Manager uses this handle to access the
  4371. definition function; you should never need to refer to this field directly.
  4372.  
  4373. Note:  When not running in 32-bit mode, the high-order byte of the
  4374.        contrlDefProc field contains some additional information that
  4375.        the Control Manager gets from the control definition ID; for
  4376.        details, see the section “Defining Your Own Controls”.
  4377.  
  4378. ContrlData is reserved for use by the control definition function, typically to hold
  4379. additional information specific to a particular control type. For example, the standard
  4380. definition function for scroll bars uses this field for a handle to the region containing
  4381. the scroll bar’s thumb. If no more than four bytes of additional information are
  4382. needed, the definition function can store the information directly in the contrlData
  4383. field rather than use a handle.
  4384.  
  4385. ContrlAction is a pointer to the control’s default action procedure, if any. The
  4386. Control Manager function TrackControl may call this procedure to respond to the
  4387. user’s dragging the mouse inside the control.
  4388.  
  4389. ContrlRfCon is the control’s reference value field, which the application may store
  4390. into and access for any purpose.
  4391.  
  4392. ContrlTitle is the control’s title, if any.
  4393.  
  4394. æKY DisposeControl
  4395. æFp Controls.p
  4396. æT PROCEDURE
  4397. æTN $A955
  4398. æD PROCEDURE DisposeControl(theControl: ControlHandle);
  4399. æDT DisposeControl(theControl);
  4400. æMM   
  4401. æRI DisposeControl procedure I-321, P-168
  4402. æC 
  4403. Assembly-language note:  The macro you invoke to call DisposeControl from
  4404.                          assembly language is named _DisposControl.
  4405.  
  4406. DisposeControl removes theControl from the screen, deletes it from its window’s
  4407. control list, and releases the memory occupied by the control record and any data
  4408. structures associated with the control.
  4409.  
  4410. æKY DragControl
  4411. æFp Controls.p
  4412. æT PROCEDURE
  4413. æTN $A967
  4414. æD PROCEDURE DragControl(theControl: ControlHandle;startPt: Point;limitRect: Rect;
  4415.     slopRect: Rect;axis: INTEGER);
  4416. æDT DragControl(theControl,startPt,limitRect,slopRect,axis);
  4417. æMM   
  4418. æRI DragControl procedure I-325
  4419. æC 
  4420. Called with the mouse button down inside theControl, DragControl pulls a dotted
  4421. outline of the control around the screen, following the movements of the mouse until
  4422. the button is released. When the mouse button is released, DragControl calls MoveControl
  4423. to move the control to the location to which it was dragged.
  4424.  
  4425. Note:  Before beginning to follow the mouse, DragControl calls the control
  4426.        definition function to allow it to do its own “custom dragging” if
  4427.        it chooses. If the definition function doesn’t choose to do any
  4428.        custom dragging, DragControl uses the default method of dragging
  4429.        described here.
  4430.  
  4431. The startPt, limitRect, slopRect, and axis parameters have the same meaning as for
  4432. the Window Manager function DragGrayRgn. These parameters are reviewed briefly below;
  4433. see the description of DragGrayRgn in the Window Manager chapter for more details.
  4434.  
  4435.   •  StartPt is assumed to be the point where the mouse button was originally
  4436.      pressed, in the local coordinates of the control’s window.
  4437.   •  LimitRect limits the travel of the control’s outline, and should normally
  4438.      coincide with or be contained within the window’s content region.
  4439.   •  SlopRect allows the user some “slop” in moving the mouse; it should
  4440.      completely enclose limitRect.
  4441.   •  The axis parameter allows you to constrain the control’s motion to
  4442.      only one axis. It has one of the following values:
  4443.  
  4444.        CONST  noConstraint = 0;    {no constraint}
  4445.               hAxisOnly    = 1;    {horizontal axis only}
  4446.               vAxisOnly    = 2;    {vertical axis only}
  4447.  
  4448. Assembly-language note:  Like TrackControl, DragControl invokes the
  4449.                          macro _DragTheRgn, so you can use the global
  4450.                          variables DragHook and DragPattern.
  4451.  
  4452. æKY Draw1Control
  4453. æFp Controls.p
  4454. æT PROCEDURE
  4455. æTN $A96D
  4456. æD PROCEDURE Draw1Control(theControl: ControlHandle);
  4457. æDT Draw1Control(theControl);
  4458. æMM   
  4459. æRI Draw1Control procedure  IV-53
  4460. æC 
  4461. [128K ROM]
  4462.  
  4463. Draw1Control draws the specified control if it’s visible within the window.
  4464.  
  4465. æKY drawCntl,testCntl,calcCRgns,initCntl,dispCntl,posCntl,thumbCntl,dragCntl,autoTrack
  4466. æFp Controls.p
  4467. æC 
  4468.   { Messages to control definition function }
  4469.  
  4470.   drawCntl   = 0;    {draw the control (or control part)}
  4471.   testCntl   = 1;    {test where mouse button was pressed}
  4472.   calcCRgns  = 2;    {calculate control's region (or indicator's)}
  4473.   initCntl   = 3;    {do any additional control initialization}
  4474.   dispCntl   = 4;    {take any additional disposal actions}
  4475.   posCntl    = 5;    {reposition control's indicator and update it}
  4476.   thumbCntl  = 6;    {calculate parameters for dragging indicator}
  4477.   dragCntl   = 7;    {drag control (or its indicator)}
  4478.   autoTrack  = 8;    {execute control's action procedure}
  4479.  
  4480. æKY DrawControls
  4481. æFp Controls.p
  4482. æT PROCEDURE
  4483. æTN $A969
  4484. æD PROCEDURE DrawControls(theWindow: WindowPtr);
  4485. æDT DrawControls(theWindow);
  4486. æRT 203
  4487. æRI DrawControls procedure I-322, P-169
  4488. æC 
  4489. DrawControls draws all controls currently visible in theWindow. The controls are
  4490. drawn in reverse order of creation; thus in case of overlap the earliest-created
  4491. controls appear frontmost in the window.
  4492.  
  4493. Note:  Window Manager routines such as SelectWindow, ShowWindow, and
  4494.        BringToFront do not automatically call DrawControls to display
  4495.        the window’s controls. They just add the appropriate regions to
  4496.        the window’s update region, generating an update event. Your program
  4497.        should always call DrawControls explicitly upon receiving an update
  4498.        event for a window that contains controls.
  4499.  
  4500. æKY FindControl
  4501. æFp Controls.p
  4502. æT FUNCTION
  4503. æTN $A96C
  4504. æD FUNCTION FindControl(thePoint: Point;theWindow: WindowPtr;VAR theControl: ControlHandle): INTEGER;
  4505. æDT myVariable := FindControl(thePoint,theWindow,theControl);
  4506. æMM   
  4507. æRI FindControl function I-323, P-98, 114, 170
  4508. æC  
  4509. When the Window Manager function FindWindow reports that the mouse button was pressed
  4510. in the content region of a window, and the window contains controls, the application
  4511. should call FindControl with theWindow equal to the window pointer and thePoint equal
  4512. to the point where the mouse button was pressed (in the window’s local coordinates).
  4513. FindControl tells which of the window’s controls, if any, the mouse button was pressed
  4514. in:
  4515.  
  4516.   •  If it was pressed in a visible, active control, FindControl sets the
  4517.      whichControl parameter to the control handle and returns a part code
  4518.      identifying the part of the control that it was pressed in.
  4519.   •  If it was pressed in an invisible or inactive control, or not in any
  4520.      control, FindControl sets whichControl to NIL and returns 0 as its result.
  4521.  
  4522. Warning:  Notice that FindControl expects the mouse point in the window’s
  4523.           local coordinates, whereas FindWindow expects it in global
  4524.           coordinates. Always be sure to convert the point to local
  4525.           coordinates with the QuickDraw procedure GlobalToLocal before
  4526.           calling FindControl.
  4527.  
  4528. Note:  FindControl also returns NIL for whichControl and 0 as its result
  4529.        if the window is invisible or doesn’t contain the given point. In
  4530.        these cases, however, FindWindow wouldn’t have returned this window
  4531.        in the first place, so the situation should never arise.
  4532.  
  4533. æKY GetAuxCtl
  4534. æFp Controls.p
  4535. æT FUNCTION
  4536. æTN $AA44
  4537. æD FUNCTION GetAuxCtl(theControl: ControlHandle;VAR acHndl: AuxCtlHndl): BOOLEAN;
  4538. æDT myVariable := GetAuxCtl(theControl,acHndl);
  4539. æMM   
  4540. æRI GetAuxCtl function  V-222
  4541. æC 
  4542. [Macintosh II]
  4543.  
  4544. The GetAuxCtl function returns a handle to a control’s AuxCtlRec:
  4545.  
  4546.   •  If the given control has its own color table, the function returns TRUE.
  4547.   •  If the control used the default color set, the function returns FALSE.
  4548.   •  If the control asked to receive the default color set (theControl = NIL),
  4549.      then the function returns TRUE.
  4550.  
  4551. æKY GetCRefCon
  4552. æFp Controls.p
  4553. æT FUNCTION
  4554. æTN $A95A
  4555. æD FUNCTION GetCRefCon(theControl: ControlHandle): LONGINT;
  4556. æDT myVariable := GetCRefCon(theControl);
  4557. æRI GetCRefCon function I-327
  4558. æC 
  4559. GetCRefCon returns theControl’s current reference value.
  4560.  
  4561. æKY GetCTitle
  4562. æFp Controls.p
  4563. æT PROCEDURE
  4564. æTN $A95E
  4565. æD PROCEDURE GetCTitle(theControl: ControlHandle;VAR title: Str255);
  4566. æDT GetCTitle(theControl,title);
  4567. æRI GetCTitle procedure I-321
  4568. æC 
  4569. GetCTitle returns theControl’s title as the value of the title parameter.
  4570.  
  4571. æKY GetCtlAction
  4572. æFp Controls.p
  4573. æT FUNCTION
  4574. æTN $A96A
  4575. æD FUNCTION GetCtlAction(theControl: ControlHandle): ProcPtr;
  4576. æDT myVariable := GetCtlAction(theControl);
  4577. æRI GetCtlAction function I-328, IV-53
  4578. æC  
  4579. GetCtlAction returns a pointer to theControl’s default action procedure, if any. (It
  4580. returns whatever is in that field of the control record.)
  4581.  
  4582. æKY GetCtlMax
  4583. æFp Controls.p
  4584. æT FUNCTION
  4585. æTN $A962
  4586. æD FUNCTION GetCtlMax(theControl: ControlHandle): INTEGER;
  4587. æDT myVariable := GetCtlMax(theControl);
  4588. æRI GetCtlMax function I-327
  4589. æC 
  4590. Assembly-language note:  The macro you invoke to call GetCtlMax from
  4591.                          assembly language is named _GetMaxCtl.
  4592.  
  4593. GetCtlMax returns theControl’s maximum setting.
  4594.  
  4595. æKY GetCtlMin
  4596. æFp Controls.p
  4597. æT FUNCTION
  4598. æTN $A961
  4599. æD FUNCTION GetCtlMin(theControl: ControlHandle): INTEGER;
  4600. æDT myVariable := GetCtlMin(theControl);
  4601. æRI GetCtlMin function I-327
  4602. æC  
  4603. Assembly-language note:  The macro you invoke to call GetCtlMin from
  4604.                          assembly language is named _GetMinCtl.
  4605.  
  4606. GetCtlMin returns theControl’s minimum setting.
  4607.  
  4608. æKY GetCtlValue
  4609. æFp Controls.p
  4610. æT FUNCTION
  4611. æTN $A960
  4612. æD FUNCTION GetCtlValue(theControl: ControlHandle): INTEGER;
  4613. æDT myVariable := GetCtlValue(theControl);
  4614. æRI GetCtlValue function I-326, P-114, 171
  4615. æC 
  4616. GetCtlValue returns theControl’s current setting.
  4617.  
  4618. æKY GetCVariant
  4619. æFp Controls.p
  4620. æT FUNCTION
  4621. æTN $A809
  4622. æD FUNCTION GetCVariant(theControl: ControlHandle): INTEGER;
  4623. æDT myVariable := GetCVariant(theControl);
  4624. æRI GetCVariant function  V-222
  4625. æC 
  4626. [Macintosh Plus, Macintosh SE, and Macintosh II]
  4627.  
  4628. The GetVariant function returns the variant control value for the control described
  4629. by theControl. This value was formerly stored in the high four bits of the control
  4630. defproc handle; for future compatibility, use the GetCVariant routine to access this
  4631. value.
  4632.  
  4633. æKY GetNewControl
  4634. æFp Controls.p
  4635. æT FUNCTION
  4636. æTN $A9BE
  4637. æD FUNCTION GetNewControl(controlID: INTEGER;owner: WindowPtr): ControlHandle;
  4638. æDT myVariable := GetNewControl(controlID,owner);
  4639. æMM 
  4640. æRT 203
  4641. æRI GetNewControl function I-321, P-112, 113, 114, 172
  4642. æC 
  4643. GetNewControl creates a control from a control template stored in a resource file,
  4644. adds it to the beginning of theWindow’s control list, and returns a handle to the new
  4645. control. ControlID is the resource ID of the template. GetNewControl works exactly
  4646. the same as NewControl (above), except that it gets the initial values for the new
  4647. control’s fields from the specified control template instead of accepting them as
  4648. parameters. If the control template can’t be read from the resource file, GetNewControl
  4649. returns NIL. It releases the memory occupied by the resource before returning.
  4650.  
  4651. The system default control colors are stored in the System file and ROMResources as
  4652. 'cctb' resource = 0. By including a 'cctb' resource = 0 in your application, it is
  4653. possible to change the default colors that will be used for all controls, unless a
  4654. specific 'cctb' exists for a control defined within the application.
  4655.  
  4656. When you use GetNewControl for the control resource 'CNTL', GetNewControl will attempt
  4657. to load a 'cctb' resource with the same ID as the 'CNTL' resource ID, if one is
  4658. present. It then executes the SetCtlColor call.
  4659.  
  4660. The following part identifiers for control elements should be present in the ColorSpec.value
  4661. field:
  4662.  
  4663.   cFrameColor (0)       Frame color
  4664.   cBodyColor (1)        Fill color for body of control
  4665.   cTextColor (2)        Text color
  4666.   cThumbColor (3)       Thumb color
  4667.  
  4668. These identifiers may be present in any order; for instance, the text or indicator
  4669. color values may be stored before the fill and frame colors in the ColorSpec record
  4670. structure. If a part identifier is not found, then the first color in the color table
  4671. will be used.
  4672.  
  4673. æKY HideControl
  4674. æFp Controls.p
  4675. æT PROCEDURE
  4676. æTN $A958
  4677. æD PROCEDURE HideControl(theControl: ControlHandle);
  4678. æDT HideControl(theControl);
  4679. æMM   
  4680. æRI HideControl procedure I-322, P-113, 114, 174
  4681. æC 
  4682. HideControl makes theControl invisible. It fills the region the control occupies
  4683. within its window with the background pattern of the window’s grafPort. It also adds
  4684. the control’s enclosing rectangle to the window’s update region, so that anything
  4685. else that was previously obscured by the control will reappear on the screen. If the
  4686. control is already invisible, HideControl has no effect.
  4687.  
  4688. æKY HiliteControl
  4689. æFp Controls.p
  4690. æT PROCEDURE
  4691. æTN $A95D
  4692. æD PROCEDURE HiliteControl(theControl: ControlHandle;hiliteState: INTEGER);
  4693. æDT HiliteControl(theControl,hiliteState);
  4694. æMM   
  4695. æRI HiliteControl procedure I-322
  4696. æC 
  4697. HiliteControl changes the way theControl is highlighted. HiliteState has one of the
  4698. following values:
  4699.  
  4700.   •  The value 0 means no highlighting. (The control is active.)
  4701.   •  A value between 1 and 253 is interpreted as a part code designating
  4702.      the part of the (active) control to be highlighted.
  4703.   •  The value 255 means that the control is to be made inactive and
  4704.      highlighted accordingly.
  4705.  
  4706. Note:  The value 254 should not be used; this value is reserved for future use.
  4707.  
  4708. HiliteControl calls the control definition function to redraw the control with its
  4709. new highlighting.
  4710.  
  4711. æKY inButton,inCheckBox,inUpButton,inDownButton,inPageUp,inPageDown,inThumb
  4712. æFp Controls.p
  4713. æC 
  4714.   { Part codes }
  4715.  
  4716.   inButton      = 10;    {simple button}
  4717.   inCheckBox    = 11;    {check box or radio button}
  4718.   inUpButton    = 20;    {up arrow of a scroll bar}
  4719.   inDownButton  = 21;    {down arrow of a scroll bar}
  4720.   inPageUp      = 22;    {"page up" region of a scroll bar}
  4721.   inPageDown    = 23;    {"page down" region of a scroll bar}
  4722.   inThumb       = 129;   {thumb of a scroll bar}
  4723.  
  4724.  
  4725. æKY KillControls
  4726. æFp Controls.p
  4727. æT PROCEDURE
  4728. æTN $A956
  4729. æD PROCEDURE KillControls(theWindow: WindowPtr);
  4730. æDT KillControls(theWindow);
  4731. æMM   
  4732. æRI KillControls procedure I-321, P-113, 175
  4733. æC 
  4734. KillControls disposes of all controls associated with theWindow by calling DisposeControl
  4735. (above) for each.
  4736.  
  4737. Note:  Remember that the Window Manager procedures CloseWindow and
  4738.        DisposeWindow automatically dispose of all controls associated
  4739.        with the given window.
  4740.  
  4741. æKY MoveControl
  4742. æFp Controls.p
  4743. æT PROCEDURE
  4744. æTN $A959
  4745. æD PROCEDURE MoveControl(theControl: ControlHandle;h: INTEGER;v: INTEGER);
  4746. æDT MoveControl(theControl,h,v);
  4747. æMM   
  4748. æRI MoveControl procedure  I-325, P-113, 176
  4749. æC 
  4750. MoveControl moves theControl to a new location within its window. The top left corner
  4751. of the control’s enclosing rectangle is moved to the horizontal and vertical coordinates
  4752. h and v (given in the local coordinates of the control’s window); the bottom right
  4753. corner is adjusted accordingly, to keep the size of the rectangle the same as before.
  4754. If the control is currently visible, it’s hidden and then redrawn at its new location.
  4755.  
  4756. æKY NewControl
  4757. æFp Controls.p
  4758. æT FUNCTION
  4759. æTN $A954
  4760. æD FUNCTION NewControl(theWindow: WindowPtr;boundsRect: Rect;title: Str255;
  4761.     visible: BOOLEAN;value: INTEGER;min: INTEGER;max: INTEGER;procID: INTEGER;
  4762.     refCon: LONGINT): ControlHandle;
  4763. æDT myVariable := NewControl(theWindow,boundsRect,title,visible,value,min,
  4764.     max,procID,refCon);
  4765. æMM   
  4766. æRI NewControl function  I-319, P-112, 114, 177
  4767. æC  
  4768. NewControl creates a control, adds it to the beginning of theWindow’s control list,
  4769. and returns a handle to the new control. The values passed as parameters are stored
  4770. in the corresponding fields of the control record, as described below. The field that
  4771. determines highlighting is set to 0 (no highlighting) and the pointer to the default
  4772. action procedure is set to NIL (none).
  4773.  
  4774. Note:  The control definition function may do additional initialization,
  4775.        including changing any of the fields of the control record. The only
  4776.        standard control for which additional initialization is done is the
  4777.        scroll bar; its control definition function allocates space for a
  4778.        region to hold the thumb and stores the region handle in the
  4779.        contrlData field of the control record.
  4780.  
  4781. TheWindow is the window the new control will belong to. All coordinates pertaining to
  4782. the control will be interpreted in this window’s local coordinate system.
  4783.  
  4784. BoundsRect, given in theWindow’s local coordinates, is the rectangle that encloses
  4785. the control and thus determines its size and location. Note the following about the
  4786. enclosing rectangle for the standard controls:
  4787.  
  4788.   •  Simple buttons are drawn to fit the rectangle exactly. (The control
  4789.      definition function calls the QuickDraw procedure FrameRoundRect.) To
  4790.      allow for the tallest characters in the system font, there should be
  4791.      at least a 20-point difference between the top and bottom coordinates
  4792.      of the rectangle.
  4793.   •  For check boxes and radio buttons, there should be at least a 16-point
  4794.      difference between the top and bottom coordinates.
  4795.   •  By convention, scroll bars are 16 pixels wide, so there should be a
  4796.      16-point difference between the left and right (or top and bottom)
  4797.      coordinates. (If there isn’t, the scroll bar will be scaled to fit
  4798.      the rectangle.) A standard scroll bar should be at least 48 pixels
  4799.      long, to allow room for the scroll arrows and thumb.
  4800.  
  4801. Title is the control’s title, if any (if none, you can just pass the empty string as
  4802. the title). Be sure the title will fit in the control’s enclosing rectangle; if it
  4803. won’t it will be truncated on the right for check boxes and radio buttons, or centered
  4804. and truncated on both ends for simple buttons.
  4805.  
  4806. Note:  Some non-Roman systems write text from right-to-left, in which
  4807.        case radio buttons and check boxes are drawn with their titles
  4808.        on the left of the control.  They are also truncated on the left.
  4809.        See the Script Manager chapter for more information.
  4810.  
  4811. If the visible parameter is TRUE, NewControl draws the control.
  4812.  
  4813. Note:  It does not use the standard window updating mechanism, but
  4814.        instead draws the control immediately in the window.
  4815.  
  4816. The min and max parameters define the control’s range of possible settings; the value
  4817. parameter gives the initial setting. For controls that don’t retain a setting, such
  4818. as buttons, the values you supply for these parameters will be stored in the control
  4819. record but will never be used. So it doesn’t matter what values you give for those
  4820. controls—0 for all three parameters will do. For controls that just retain an on-or-off
  4821. setting, such as check boxes or radio buttons, min should be 0 (meaning the control
  4822. is off) and max should be 1
  4823. (meaning it’s on). For dials, you can specify whatever values are appropriate for
  4824. min, max, and value.
  4825.  
  4826. ProcID is the control definition ID, which leads to the control definition function
  4827. for this type of control. (The function is read into memory if it
  4828. isn’t already in memory.) The control definition IDs for the standard control types
  4829. are listed above under “Controls and Resources”. Control definition IDs for custom
  4830. control types are discussed later under “Defining Your Own Controls”.
  4831.  
  4832. RefCon is the control’s reference value, set and used only by your application.
  4833.  
  4834. æKY noConstraint,hAxisOnly,vAxisOnly
  4835. æFp Controls.p
  4836. æC 
  4837.   { Axis constraints for DragControl }
  4838.  
  4839.   noConstraint  = 0;     {no constraint}
  4840.   hAxisOnly     = 1;     {horizontal axis only}
  4841.   vAxisOnly     = 2;     {vertical axis only}
  4842.  
  4843. æKY pushButProc,checkBoxProc,radioButProc,useWFont,scrollBarProc
  4844. æFp Controls.p
  4845. æC 
  4846.   { Control definition IDs }
  4847.  
  4848.   pushButProc    = 0;    {simple button}
  4849.   checkBoxProc   = 1;    {check box}
  4850.   radioButProc   = 2;    {radio button}
  4851.   useWFont       = 8;    {add to above to use window's font}
  4852.   scrollBarProc  = 16;   {scroll bar}
  4853.  
  4854. æKY SetCRefCon
  4855. æFp Controls.p
  4856. æT PROCEDURE
  4857. æTN $A95B
  4858. æD PROCEDURE SetCRefCon(theControl: ControlHandle;data: LONGINT);
  4859. æDT SetCRefCon(theControl,data);
  4860. æRI SetCRefCon procedure I-327
  4861. æC 
  4862. SetCRefCon sets theControl’s reference value to the given data.
  4863.  
  4864. æKY SetCTitle
  4865. æFp Controls.p
  4866. æT PROCEDURE
  4867. æTN $A95F
  4868. æD PROCEDURE SetCTitle(theControl: ControlHandle;title: Str255);
  4869. æDT SetCTitle(theControl,title);
  4870. æMM   
  4871. æRI SetCTitle procedure I-321
  4872. æC  
  4873. SetCTitle sets theControl’s title to the given string and redraws the control.
  4874.  
  4875. æKY SetCtlAction
  4876. æFp Controls.p
  4877. æT PROCEDURE
  4878. æTN $A96B
  4879. æD PROCEDURE SetCtlAction(theControl: ControlHandle;actionProc: ProcPtr);
  4880. æDT SetCtlAction(theControl,actionProc);
  4881. æRI SetCtlAction procedure I-328
  4882. æC 
  4883. SetCtlAction sets theControl’s default action procedure to actionProc.
  4884.  
  4885. æKY SetCtlColor
  4886. æFp Controls.p
  4887. æT PROCEDURE
  4888. æTN $AA43
  4889. æD PROCEDURE SetCtlColor(theControl: ControlHandle;newColorTable: CCTabHandle);
  4890. æDT SetCtlColor(theControl,newColorTable);
  4891. æMM   
  4892. æRI SetCtlColor procedure  V-222
  4893. æC 
  4894. [Macintosh II]
  4895.  
  4896. The SetCtlColor procedure sets or modifies a control’s color table.  If the control
  4897. currently has no auxiliary control record, a new one is created with the given color
  4898. table and added to the head of the auxiliary control list. If there is already an
  4899. auxiliary record for the control, its color table is replaced by the contents of
  4900. newColorTable.
  4901.  
  4902. If newColorTable has the same contents as the default color table, the
  4903. control’s existing auxiliary record and color table are removed from the auxiliary
  4904. control list and deallocated.  If theControl = NIL, the operation modifies the default
  4905. color table itself. If the control is visible, it will be redrawn by SetCtlColor
  4906. using the new color table.
  4907.  
  4908. æKY SetCtlMax
  4909. æFp Controls.p
  4910. æT PROCEDURE
  4911. æTN $A965
  4912. æD PROCEDURE SetCtlMax(theControl: ControlHandle;maxValue: INTEGER);
  4913. æDT SetCtlMax(theControl,maxValue);
  4914. æMM   
  4915. æRI SetCtlMax procedure I-327
  4916. æC 
  4917. Assembly-language note:  The macro you invoke to call SetCtlMax from
  4918.                          assembly language is named _SetMaxCtl.
  4919.  
  4920. SetCtlMax sets theControl’s maximum setting to maxValue and redraws the control to
  4921. reflect the new range. If the control’s current setting is greater than maxValue, the
  4922. setting is changed to the new maximum.
  4923.  
  4924. Note:  If you set the maximum setting of a scroll bar equal to its minimum
  4925.        setting, the control definition function will make the scroll bar
  4926.        inactive.
  4927.  
  4928. æKY SetCtlMin
  4929. æFp Controls.p
  4930. æT PROCEDURE
  4931. æTN $A964
  4932. æD PROCEDURE SetCtlMin(theControl: ControlHandle;minValue: INTEGER);
  4933. æDT SetCtlMin(theControl,minValue);
  4934. æMM   
  4935. æRI SetCtlMin procedure I-326
  4936. æC 
  4937. Assembly-language note:  The macro you invoke to call SetCtlMin from
  4938.                          assembly language is named _SetMinCtl.
  4939.  
  4940. SetCtlMin sets theControl’s minimum setting to minValue and redraws the control to
  4941. reflect the new range. If the control’s current setting is less than minValue, the
  4942. setting is changed to the new minimum.
  4943.  
  4944. æKY SetCtlValue
  4945. æFp Controls.p
  4946. æT PROCEDURE
  4947. æTN $A963
  4948. æD PROCEDURE SetCtlValue(theControl: ControlHandle;theValue: INTEGER);
  4949. æDT SetCtlValue(theControl,theValue);
  4950. æMM 
  4951. æRT 197
  4952. æRI SetCtlValue procedure I-326
  4953. æC 
  4954. SetCtlValue sets theControl’s current setting to theValue and redraws the control to
  4955. reflect the new setting. For check boxes and radio buttons, the value 1 fills the
  4956. control with the appropriate mark, and 0 clears it. For scroll bars, SetCtlValue
  4957. redraws the thumb where appropriate.
  4958.  
  4959. If the specified value is out of range, it’s forced to the nearest endpoint of the
  4960. current range (that is, if theValue is less than the minimum setting, SetCtlValue
  4961. sets the current setting to the minimum; if theValue is greater than the maximum
  4962. setting, it sets the current setting to the maximum).
  4963.  
  4964. æKY ShowControl
  4965. æFp Controls.p
  4966. æT PROCEDURE
  4967. æTN $A957
  4968. æD PROCEDURE ShowControl(theControl: ControlHandle);
  4969. æDT ShowControl(theControl);
  4970. æMM 
  4971. æRT 197
  4972. æRI ShowControl procedure I-322, P-113, 114, 181
  4973. æC 
  4974. ShowControl makes theControl visible. The control is drawn in its window but may be
  4975. completely or partially obscured by overlapping windows or other objects. If the
  4976. control is already visible, ShowControl has no effect.
  4977.  
  4978. æKY SizeControl
  4979. æFp Controls.p
  4980. æT PROCEDURE
  4981. æTN $A95C
  4982. æD PROCEDURE SizeControl(theControl: ControlHandle;w: INTEGER;h: INTEGER);
  4983. æDT SizeControl(theControl,w,h);
  4984. æMM   
  4985. æRI SizeControl procedure I-326, P-113, 181
  4986. æC 
  4987. SizeControl changes the size of theControl’s enclosing rectangle. The bottom right
  4988. corner of the rectangle is adjusted to set the rectangle’s width and height to the
  4989. number of pixels specified by w and h; the position of the top left corner is not
  4990. changed. If the control is currently visible, it’s hidden and then redrawn in its new
  4991. size.
  4992.  
  4993. æKY TestControl
  4994. æFp Controls.p
  4995. æT FUNCTION
  4996. æTN $A966
  4997. æD FUNCTION TestControl(theControl: ControlHandle;thePt: Point): INTEGER;
  4998. æDT myVariable := TestControl(theControl,thePt);
  4999. æMM   
  5000. æRI TestControl procedure I-325
  5001. æC  
  5002. If theControl is visible and active, TestControl tests which part of the control
  5003. contains thePoint (in the local coordinates of the control’s window); it returns the
  5004. corresponding part code, or 0 if the point is outside the control. If the control is
  5005. invisible or inactive, TestControl returns 0. TestControl is called by FindControl
  5006. and TrackControl; normally you won’t need to call it yourself.
  5007.  
  5008. æKY TrackControl
  5009. æFp Controls.p
  5010. æT FUNCTION
  5011. æTN $A968
  5012. æD FUNCTION TrackControl(theControl: ControlHandle;thePoint: Point;actionProc: ProcPtr): INTEGER;
  5013. æDT myVariable := TrackControl(theControl,thePoint,actionProc);
  5014. æMM   
  5015. æRI TrackControl function I-323, P-114, 184
  5016. æC 
  5017. When the mouse button is pressed in a visible, active control, the application should
  5018. call TrackControl with theControl equal to the control handle and startPt equal to
  5019. the point where the mouse button was pressed (in the local coordinates of the control’s
  5020. window). TrackControl follows the movements of the mouse and responds in whatever way
  5021. is appropriate until the mouse button is released; the exact response depends on the
  5022. type of control and the part of the control in which the mouse button was pressed. If
  5023. highlighting is appropriate, TrackControl does the highlighting, and undoes it before
  5024. returning. When the mouse button is released, TrackControl returns with the part code
  5025. if the mouse is in the same part of the control that it was originally in, or with 0
  5026. if not
  5027. (in which case the application should do nothing).
  5028.  
  5029. If the mouse button was pressed in an indicator, TrackControl drags a dotted outline
  5030. of it to follow the mouse. When the mouse button is released, TrackControl calls the
  5031. control definition function to reposition the control’s indicator. The control definition
  5032. function for scroll bars responds by redrawing the thumb, calculating the control’s
  5033. current setting based on the new relative position of the thumb, and storing the
  5034. current setting in the control record; for example, if the minimum and maximum settings
  5035. are 0 and 10, and the thumb is in the middle of the scroll bar, 5 is stored as the
  5036. current setting. The application must then scroll to the corresponding relative
  5037. position in the document.
  5038.  
  5039. TrackControl may take additional actions beyond highlighting the control or dragging
  5040. the indicator, depending on the value passed in the actionProc parameter, as described
  5041. below. The following tells you what to pass for the standard control types; for a
  5042. custom control, what you pass will depend on how the control is defined.
  5043.  
  5044.   •  If actionProc is NIL, TrackControl performs no additional actions. This
  5045.      is appropriate for simple buttons, check boxes, radio buttons, and the
  5046.      thumb of a scroll bar.
  5047.   •  ActionProc may be a pointer to an action procedure that defines some
  5048.      action to be performed repeatedly for as long as the user holds down
  5049.      the mouse button. (See below for details.)
  5050.   •  If actionProc is POINTER(–1), TrackControl looks in the control record
  5051.      for a pointer to the control’s default action procedure. If that field
  5052.      of the control record contains a procedure pointer, TrackControl uses
  5053.      the action procedure it points to; if the field contains POINTER (–1),
  5054.      TrackControl calls the control definition function to perform the
  5055.      necessary action. (If the field contains NIL, TrackControl does nothing.)
  5056.  
  5057. The action procedure in the control definition function is described in the section
  5058. “Defining Your Own Controls”. The following paragraphs describe only the action
  5059. procedure whose pointer is passed in the actionProc parameter or stored in the control
  5060. record.
  5061.  
  5062. If the mouse button was pressed in an indicator, the action procedure (if any) should
  5063. have no parameters. This procedure must allow for the fact that the mouse may not be
  5064. inside the original control part.
  5065.  
  5066. If the mouse button was pressed in a control part other than an indicator, the action
  5067. procedure should be of the form
  5068.  
  5069. PROCEDURE MyAction (theControl:  ControlHandle; partCode:  INTEGER);
  5070.  
  5071. In this case, TrackControl passes the control handle and the part code to the action
  5072. procedure. (It passes 0 in the partCode parameter if the mouse has moved outside the
  5073. original control part.) As an example of this type of action procedure, consider what
  5074. should happen when the mouse button is pressed in a scroll arrow or paging region in
  5075. a scroll bar. For these cases, your action procedure should examine the part code to
  5076. determine exactly where the mouse button was pressed, scroll up or down a line or
  5077. page as appropriate, and call SetCtlValue to change the control’s setting and redraw
  5078. the thumb.
  5079.  
  5080. Warning:  Since it has a different number of parameters depending on whether
  5081.           the mouse button was pressed in an indicator or elsewhere, the
  5082.           action procedure you pass to TrackControl (or whose pointer you
  5083.           store in the control record) can be set up for only one case or
  5084.           the other. If you store a pointer to a default action procedure
  5085.           in a control record, be sure it will be used only when appropriate
  5086.           for that type of action procedure. The only way to specify actions
  5087.           in response to all mouse-down events in a control, regardless of
  5088.           whether they’re in an indicator, is via the control definition
  5089.           function.
  5090.  
  5091. Assembly-language note:  If you store a pointer to a procedure in the global
  5092.                          variable DragHook, that procedure will be called
  5093.                          repeatedly (with no parameters) for as long as the
  5094.                          user holds down the mouse button. TrackControl
  5095.                          invokes the Window Manager macro _DragTheRgn,
  5096.                          which calls the DragHook procedure. _DragTheRgn
  5097.                          uses the pattern stored in the global variable
  5098.                          DragPattern for the dragged outline of the indicator.
  5099.  
  5100. æKY UpdtControl
  5101. æFp Controls.p
  5102. æT PROCEDURE
  5103. æTN $A953
  5104. æD PROCEDURE UpdtControl(theWindow: WindowPtr;updateRgn: RgnHandle);
  5105. æDT UpdtControl(theWindow,updateRgn);
  5106. æMM   
  5107. æRI UpdtControl procedure  IV-53
  5108. æC  
  5109. [128K ROM]
  5110.  
  5111. UpdtControl is a faster version of the DrawControls procedure. Instead of drawing all
  5112. of the controls in theWindow, UpdtControl draws only the controls that are in the
  5113. specified update region. UpdtControl is called in response to an update event, and is
  5114. usually bracketed by calls to the Window Manager procedures BeginUpdate and EndUpdate.
  5115. UpdateRgn should be set to the visRgn of theWindow’s port (for more details, see the
  5116. BeginUpdate procedure in the Window Manager chapter).
  5117.  
  5118. Note:  In general, controls are in a dialog box and are automatically
  5119.        drawn by the DrawDialog procedure.
  5120.  
  5121. æKY CTabHandle,CTabPtr,ColorTable
  5122. æFp Controls.p
  5123. æT TYPE
  5124. æC CTabPtr = ^ColorTable;
  5125. CTabHandle = ^CTabPtr;
  5126. ColorTable = RECORD
  5127.    ctSeed: LONGINT;                        {unique identifier for table}
  5128.    ctFlags: INTEGER;                       {high bit: 0 = PixMap; 1 = device}
  5129.    ctSize: INTEGER;                        {number of entries in CTTable}
  5130.    ctTable: CSpecArray;                    {array [0..0] of ColorSpec}
  5131.    END;
  5132.  
  5133. æKY CtlCTab,CCTabPtr,CCTabHandle
  5134. æFp Controls.p
  5135. æT TYPE
  5136. æC CCTabPtr = ^CtlCTab;
  5137. CCTabHandle = ^CCTabPtr;
  5138. CtlCTab = RECORD
  5139.     ccSeed: LONGINT;            {reserved}
  5140.     ccRider: INTEGER;            {see what you have done - reserved}
  5141.     ctSize: INTEGER;            {usually 3 for controls}
  5142.     ctTable: ARRAY [0..3] OF ColorSpec;
  5143.     END;
  5144.  
  5145. The contents and meaning of a control’s color table are determined by its control
  5146. definition function (see “The Control Color Table Resource” section). The CTabHandle
  5147. parameter used in the Color Control Manager routines provides a handle to the control
  5148. color table. The components of a control color table are defined as follows:
  5149.  
  5150. TYPE
  5151.   CCTabHandle = ^CCTabPtr;
  5152.   CCTabPtr    = ^CtlCTab;
  5153.   CtlCTab     = RECORD
  5154.                   ccSeed:      LONGINT;    {not used for controls}
  5155.                   ccRider:     INTEGER;    {not used for controls}
  5156.                   ctSize:      INTEGER;    {number of entries in table –1}
  5157.                   ctTable:     cSpecArray  {array of ColorSpec records}
  5158.                 END;
  5159.  
  5160. Field descriptions
  5161.  
  5162. ccSeed        The ccSeed field is unused in control color tables.
  5163.  
  5164. ccRider       The ccRider field is unused in control color tables.
  5165.  
  5166. ctSize        The ctSize field defines the number of elements in the table,
  5167.               minus one. For controls drawn with the standard definition
  5168.               procedure, this field is always 3.
  5169.  
  5170. ctTable       The ctTable field holds an array of colorSpec records. Each
  5171.               colorSpec is made up of a partIdentifier field and a partRGB
  5172.               field. The partIdentifier field holds an integer which
  5173.               associates an RGBColor to a particular part of the control.
  5174.               The definition procedures attempt to find the appropriate part
  5175.               identifier when preparing to draw a part. If that part
  5176.               identifier is not found, the first color in the table is
  5177.               used to draw the part. The part identifiers can appear in any
  5178.               order in the table. The partRGB field specifies a standard RGB
  5179.               color record, indicating what absolute color will be used to
  5180.               draw the control part found in the partIdentifier field.
  5181.  
  5182. A standard control color table is shown in Figure 6.
  5183.  
  5184. •••Refer to Figure 6.•••
  5185.  
  5186. Figure 6–Control Color Table
  5187.  
  5188. The 'cctb' resource is an exact image of this control table data structure, and is
  5189. stored in the same format as 'clut' color table resources.
  5190.  
  5191. Standard buttons, check boxes, and radio buttons use a four-element color table with
  5192. part identifiers as shown below:
  5193.  
  5194.   cFrameColor (0)       Frame color
  5195.   cBodyColor (1)        Fill color for body of control
  5196.   cTextColor (2)        Text color
  5197.   cThumbColor (3)       Unused
  5198.  
  5199. When highlighted, plain buttons exchange their body and text colors (colors 1 and 2);
  5200. check boxes and radio buttons change their appearance without changing colors.  All
  5201. three types indicate deactivation by dimming their text with no change in colors.
  5202.  
  5203. Standard scroll bars use a four-element color table with part identifiers as shown
  5204. below:
  5205.  
  5206.   cFrameColor (0)       Frame color, foreground color for shaft and arrows
  5207.   cBodyColor (1         Background color for shaft and arrows
  5208.   cTextColor (2)        Unused
  5209.   cThumbColor (3)       Fill color for thumb
  5210.  
  5211. When highlighted, the arrows are filled with the foreground color (color 0) within
  5212. the arrow outline. A deactivated scroll bar shows no indicator, and displays its
  5213. shaft in solid background color (color 1), with no pattern.
  5214.  
  5215. The 'cctb' resource = 0 is read into the application heap when the application starts,
  5216. and serves as the default control color table. The last record in the auxiliary
  5217. control list points to the default 'cctb' resource. When drawing a control, the
  5218. standard control definition function searches the list for an auxiliary control
  5219. record whose acOwner points to the control being drawn.  If it finds such a record,
  5220. it uses the color table designated by that record; if it doesn’t find one before
  5221. reaching the default record at the end of the list, it uses the default color table
  5222. instead. All types of controls share the same default record. The default auxiliary
  5223. control record is recognized by NIL values in both its acNext and acOwner fields; the
  5224. application must not change these fields.
  5225.  
  5226. A nonstandard control definition function can use color tables of any desired size
  5227. and define their contents in any way it wishes, except that part indices 1 to 127 are
  5228. reserved for system definition.  Any such nonstandard function should take care to
  5229. bypass the defaulting mechanism just described, by allocating an explicit auxiliary
  5230. record for every control it creates.
  5231.  
  5232.  
  5233. æKY CursorCtl.p
  5234. æKL Hide_Cursor
  5235. InitCursorCtl
  5236. RotateCursor
  5237. Show_Cursor
  5238. SpinCursor
  5239.  
  5240. Acur
  5241. acurHandle
  5242. acurPtr
  5243. ARROW_CURSOR
  5244. CROSS_CURSOR
  5245. Cursors
  5246. HIDDEN_CURSOR
  5247. I_BEAM_CURSOR
  5248. PLUS_CURSOR
  5249. WATCH_CURSOR
  5250.  
  5251.  
  5252. æKY Acur,acurPtr,acurHandle
  5253. æFp CursorCtl.p
  5254. æT TYPE
  5255. æC acurPtr = ^Acur;
  5256. acurHandle = ^acurPtr;
  5257. Acur = RECORD
  5258.    n: INTEGER;         {Number of cursors ("frames of film")}
  5259.    index: INTEGER;     { Next frame to show <for internal use>}
  5260.    frame1: INTEGER;    {'CURS' resource id for frame #1}
  5261.    fill1: INTEGER;     {<for internal use>}
  5262.    frame2: INTEGER;    {'CURS' resource id for frame #2}
  5263.    fill2: INTEGER;     {<for internal use>}
  5264.    frameN: INTEGER;    {'CURS' resource id for frame #N}
  5265.    fillN: INTEGER;     {<for internal use>}
  5266.    END;
  5267.  
  5268. æKY Cursors,HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,ARROW_CURSOR
  5269. æFp CursorCtl.p
  5270. æC Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  5271. ARROW_CURSOR);
  5272.  
  5273. æKY Hide_Cursor
  5274. æFp CursorCtl.p
  5275. æT PROCEDURE
  5276. æD PROCEDURE Hide_Cursor;
  5277. æDT Hide_Cursor;
  5278. æC 
  5279. { Hide the cursor if it is showing.This is this unit's call to the Mac
  5280. HideCursor routine.Thus the Mac cursor level is decremented by one when this
  5281. routine is called.
  5282.  }
  5283.  
  5284. æKY InitCursorCtl
  5285. æFp CursorCtl.p
  5286. æT PROCEDURE
  5287. æD PROCEDURE InitCursorCtl(newCursors: UNIV acurHandle);
  5288. æDT InitCursorCtl(newCursors);
  5289. æC 
  5290. { Initialize the CursorCtl unit. This should be called once prior to calling
  5291. RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  5292. Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  5293. 'acur' resource and the 'CURS' resources specified by the 'acur' resource
  5294. ids.  If any of the resources cannot be loaded, the cursor will not be
  5295. changed.
  5296.  
  5297. The 'acur' resource is assumed to either be in the currently running tool or
  5298. application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  5299. resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  5300. the System file.
  5301.  
  5302. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  5303. resource designated by the caller and it will be used instead of doing a
  5304. GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  5305. calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  5306. the user the first time it is called.  However, the possible disadvantage of
  5307. using this technique is that the resource memory allocated may have
  5308. undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  5309. has the advantage of causing the allocation at a specific time determined by
  5310. the user.
  5311.  
  5312. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.  Specifically,
  5313. it changes each FrameN/fillN integer pair to a handle to the corresponding
  5314. 'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  5315. InitCursorCtl is called, the caller must guarantee NewCursors always points to
  5316. a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  5317. caller who wants to repeatly use multiple 'acur' resources during execution of
  5318. their programs.
  5319.  }
  5320.  
  5321. æKY RotateCursor
  5322. æFp CursorCtl.p
  5323. æT PROCEDURE
  5324. æD PROCEDURE RotateCursor(counter: LONGINT);
  5325. æDT RotateCursor(counter);
  5326. æC 
  5327. { RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  5328. animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  5329. ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  5330. or decrementing index maintained by the caller). A positive counter sequences
  5331. forward through the cursors (e.g., it rotates the "beach ball" cursor
  5332. clockwise), and a negative cursor sequences through the cursors backwards
  5333. (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  5334. RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  5335.   It is assumed the cursor is visible from a prior Show_Cursor call.
  5336.  }
  5337.  
  5338. æKY Show_Cursor
  5339. æFp CursorCtl.p
  5340. æT PROCEDURE
  5341. æD PROCEDURE Show_Cursor(cursorKind: Cursors);
  5342. æDT Show_Cursor(cursorKind);
  5343. æC 
  5344. { Increment the cursor level, which may have been decremented by Hide_Cursor,
  5345. and display the specified cursor if the level becomes 0 (it is never
  5346. incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  5347. one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  5348. WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is 
  5349. done for the specified cursor prior to doing a ShowCursor.  HIDDEN_CURSOR just
  5350. causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  5351. there is already a grafPort set up pointed to by 0(A5).
  5352.  }
  5353.  
  5354. æKY SpinCursor
  5355. æFp CursorCtl.p
  5356. æT PROCEDURE
  5357. æD PROCEDURE SpinCursor(increment: INTEGER);
  5358. æDT SpinCursor(increment);
  5359. æC 
  5360. { SpinCursor is similar in function to RotateCursor, except that instead of
  5361. passing a counter, an Increment is passed an added to a counter maintained
  5362. here.  SpinCursor is provided for those users who do not happen to have a
  5363. convenient counter handy but still want to use the spinning "beach ball"
  5364. cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  5365. increment sequences forward through the curos (rotating the "beach ball"
  5366. cursor clockwise), and a negative increment sequences backward through the
  5367. cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  5368. for the increment resets the counter to zero.  Note, it is the increment, and
  5369. not the value of the counter that determines the sequencing direction of the
  5370. cursor (and hence the spin direction of the "beach ball" cursor).
  5371.  }
  5372.  
  5373.  
  5374. æKY Desk.p
  5375. æKL CloseDeskAcc
  5376. OpenDeskAcc
  5377. SystemClick
  5378. SystemEdit
  5379. SystemEvent
  5380. SystemMenu
  5381. SystemTask
  5382.  
  5383. accClear
  5384. accCopy
  5385. accCursor
  5386. accCut
  5387. accEvent
  5388. accMenu
  5389. accPaste
  5390. accRun
  5391. accUndo
  5392. goodbye
  5393.  
  5394.  
  5395. æKY accClear
  5396. æFp Desk.p
  5397. æC accClear = 73;
  5398.  
  5399. æKY accCopy
  5400. æFp Desk.p
  5401. æC accCopy = 71;
  5402.  
  5403. æKY accCursor
  5404. æFp Desk.p
  5405. æC accCursor = 66;
  5406.  
  5407. æKY accCut
  5408. æFp Desk.p
  5409. æC accCut = 70;
  5410.  
  5411. æKY accEvent
  5412. æFp Desk.p
  5413. æC accEvent = 64;
  5414.  
  5415. æKY accMenu
  5416. æFp Desk.p
  5417. æC accMenu = 67;
  5418.  
  5419. æKY accPaste
  5420. æFp Desk.p
  5421. æC accPaste = 72;
  5422.  
  5423. æKY accRun
  5424. æFp Desk.p
  5425. æC accRun = 65;
  5426.  
  5427. æKY accUndo
  5428. æFp Desk.p
  5429. æC accUndo = 68;
  5430.  
  5431. æKY CloseDeskAcc
  5432. æFp Desk.p
  5433. æT PROCEDURE
  5434. æTN $A9B7
  5435. æD PROCEDURE CloseDeskAcc(refNum: INTEGER);
  5436. æDT CloseDeskAcc(refNum);
  5437. æRI CloseDeskAcc procedure I-440
  5438. æC 
  5439. When a system window is active and the user chooses Close from the File menu, call
  5440. CloseDeskAcc to close the desk accessory. RefNum is the driver reference number for
  5441. the desk accessory, which you get from the windowKind field of its window.
  5442.  
  5443. The Desk Manager automatically closes a desk accessory if the user clicks its close
  5444. box. Also, since the application heap is released when the application terminates,
  5445. every desk accessory goes away at that time.
  5446.  
  5447. æKY goodbye
  5448. æFp Desk.p
  5449. æC goodbye = -1; {goodbye message}
  5450.  
  5451. æKY OpenDeskAcc
  5452. æFp Desk.p
  5453. æT FUNCTION
  5454. æTN $A9B6
  5455. æD FUNCTION OpenDeskAcc(theAcc: Str255): INTEGER;
  5456. æDT myVariable := OpenDeskAcc(theAcc);
  5457. æMM   
  5458. æRI OpenDeskAcc function I-440
  5459. æC 
  5460. OpenDeskAcc opens the desk accessory having the given name and displays its window
  5461. (if any) as the active window. The name is the accessory’s resource name, which you
  5462. get from the Apple menu by calling the Menu Manager procedure GetItem. OpenDeskAcc
  5463. calls the Resource Manager to read the desk accessory from the resource file into the
  5464. application heap.
  5465.  
  5466. You should ignore the value returned by OpenDeskAcc. If the desk accessory is successfully
  5467. opened, the function result is its driver reference number. However, if the desk
  5468. accessory can’t be opened, the function result is undefined; the accessory will have
  5469. taken care of informing the user of the problem (such as memory full) and won’t
  5470. display itself.
  5471.  
  5472. Warning:  Early versions of some desk accessories may set the current
  5473.           grafPort to the accessory’s port upon return from OpenDeskAcc.
  5474.           To be safe, you should bracket your call to OpenDeskAcc with
  5475.           calls to the QuickDraw procedures GetPort and SetPort, to save
  5476.           and restore the current port.
  5477.  
  5478. Note:  Programmers concerned about the amount of available memory should
  5479.        be aware that an open desk accessory uses from 1K to 3K bytes of
  5480.        heap space in addition to the space needed for the accessory itself.
  5481.        The desk accessory is responsible for determining whether there is
  5482.        sufficient memory for it to run; this can be done by calling
  5483.        SizeResource followed by ResrvMem.
  5484.  
  5485. æKY SystemClick
  5486. æFp Desk.p
  5487. æT PROCEDURE
  5488. æTN $A9B3
  5489. æD PROCEDURE SystemClick(theEvent: EventRecord;theWindow: WindowPtr);
  5490. æDT SystemClick(theEvent,theWindow);
  5491. æMM   
  5492. æRI SystemClick procedure I-441, P-35, 182
  5493. æC 
  5494. When a mouse-down event occurs and the Window Manager function FindWindow reports
  5495. that the mouse button was pressed in a system window, the application should call
  5496. SystemClick with the event record and the window pointer. If the given window belongs
  5497. to a desk accessory, SystemClick sees that the event gets handled properly.
  5498.  
  5499. SystemClick determines which part of the desk accessory’s window the mouse button was
  5500. pressed in, and responds accordingly (similar to the way your application responds to
  5501. mouse activities in its own windows).
  5502.  
  5503.   •  If the mouse button was pressed in the content region of the window
  5504.      and the window was active, SystemClick sends the mouse-down event to
  5505.      the desk accessory, which processes it as appropriate.
  5506.   •  If the mouse button was pressed in the content region and the window
  5507.      was inactive, SystemClick makes it the active window.
  5508.   •  If the mouse button was pressed in the drag region, SystemClick calls
  5509.      the Window Manager procedure DragWindow to pull an outline of the window
  5510.      across the screen and move the window to a new location. If the window
  5511.      was inactive, DragWindow also makes it the active window (unless the
  5512.      Command key was pressed along with the mouse button).
  5513.   •  If the mouse button was pressed in the go-away region, SystemClick calls
  5514.      the Window Manager function TrackGoAway to determine whether the mouse
  5515.      is still inside the go-away region when the click is completed:  If
  5516.      so, it tells the desk accessory to close itself; otherwise, it does
  5517.      nothing.
  5518.  
  5519. æKY SystemEdit
  5520. æFp Desk.p
  5521. æT FUNCTION
  5522. æTN $A9C2
  5523. æD FUNCTION SystemEdit(editCmd: INTEGER): BOOLEAN;
  5524. æDT myVariable := SystemEdit(editCmd);
  5525. æMM 
  5526. æRT 180, 215
  5527. æRI SystemEdit function I-441
  5528. æC 
  5529. Assembly-language note:  The macro you invoke to call SystemEdit from
  5530.                          assembly language is named _SysEdit.
  5531.  
  5532. Call SystemEdit when there’s a mouse-down event in the menu bar and the user chooses
  5533. one of the five standard editing commands from the Edit menu. Pass one of the following
  5534. as the value of the editCmd parameter:
  5535.  
  5536.   editCmd    Editing command
  5537.  
  5538.     0            Undo
  5539.     2            Cut
  5540.     3            Copy
  5541.     4            Paste
  5542.     5            Clear
  5543.  
  5544. If your Edit menu contains these five commands in the standard arrangement (the order
  5545. listed above, with a dividing line between Undo and Cut), you can simply call
  5546.  
  5547.   SystemEdit(menuItem-1)
  5548.  
  5549. where menuItem is the menu item number.
  5550.  
  5551. If the active window doesn’t belong to a desk accessory, SystemEdit returns FALSE;
  5552. the application should then process the editing command as usual. If the active
  5553. window does belong to a desk accessory, SystemEdit asks that accessory to process the
  5554. command and returns TRUE; in this case, the application should ignore the command.
  5555.  
  5556. Note:  It’s up to the application to make sure desk accessories get
  5557.        their editing commands that are chosen from the Edit menu. In
  5558.        particular, make sure your application hasn’t disabled the Edit
  5559.        menu or any of the five standard commands when a desk accessory
  5560.        is activated.
  5561.  
  5562. æKY SystemEvent
  5563. æFp Desk.p
  5564. æT FUNCTION
  5565. æTN $A9B2
  5566. æD FUNCTION SystemEvent(theEvent: EventRecord): BOOLEAN;
  5567. æDT myVariable := SystemEvent(theEvent);
  5568. æRT 5,85
  5569. æRI SystemEvent function I-442, N5-1, N85-1
  5570. æC  
  5571. SystemEvent is called only by the Toolbox Event Manager function GetNextEvent when it
  5572. receives an event, to determine whether the event should be handled by the application
  5573. or by the system. If the given event should be handled by the application, SystemEvent
  5574. returns FALSE; otherwise, it calls the appropriate system code to handle the event
  5575. and returns TRUE.
  5576.  
  5577. In the case of a null or mouse-down event, SystemEvent does nothing but return FALSE.
  5578. Notice that it responds this way to a mouse-down event even though the event may in
  5579. fact have occurred in a system window (and therefore may have to be handled by the
  5580. system). The reason for this is that the check for exactly where the event occurred
  5581. (via the Window Manager function FindWindow) is made later by the application and so
  5582. would be made twice if SystemEvent were also to do it. To avoid this duplication,
  5583. SystemEvent passes the event on to the application and lets it make the sole call to
  5584. FindWindow. Should FindWindow reveal that the mouse-down event did occur in a system
  5585. window, the application can then call SystemClick, as described above, to get the
  5586. system to handle it.
  5587.  
  5588. If the given event is a mouse-up or any keyboard event (including keyboard equivalents
  5589. of commands), SystemEvent checks whether the active window belongs to a desk accessory
  5590. and whether that accessory can handle this type of event. If so, it sends the event
  5591. to the desk accessory and returns TRUE; otherwise, it returns FALSE.
  5592.  
  5593. If SystemEvent is passed an activate or update event, it checks whether the window
  5594. the event occurred in is a system window belonging to a desk accessory and whether
  5595. that accessory can handle this type of event. If so, it sends the event to the desk
  5596. accessory and returns TRUE; otherwise, it returns FALSE.
  5597.  
  5598. Note:  It’s unlikely that a desk accessory would not be set up to handle
  5599.        keyboard, activate, and update events, or that it would handle
  5600.        mouse-up events.
  5601.  
  5602.        If the given event is a disk-inserted event, SystemEvent does some
  5603.        low-level processing (by calling the File Manager function MountVol)
  5604.        but passes the event on to the application by returning FALSE, in
  5605.        case the application wants to do further processing. Finally,
  5606.        SystemEvent returns FALSE for network, device driver, and
  5607.        application-defined events.
  5608.  
  5609. Assembly-language note:  Advanced programmers can make SystemEvent
  5610.                          always return FALSE by setting the global
  5611.                          variable SEvtEnb (a byte) to 0.
  5612.  
  5613. æKY SystemMenu
  5614. æFp Desk.p
  5615. æT PROCEDURE
  5616. æTN $A9B5
  5617. æD PROCEDURE SystemMenu(menuResult: LONGINT);
  5618. æDT SystemMenu(menuResult);
  5619. æMM   
  5620. æRI SystemMenu procedure I-443
  5621. æC  
  5622. SystemMenu is called only by the Menu Manager functions MenuSelect and MenuKey, when
  5623. an item in a menu belonging to a desk accessory has been chosen. The menuResult
  5624. parameter has the same format as the value returned by MenuSelect and MenuKey:  the
  5625. menu ID in the high-order word and the menu item number in the low-order word. (The
  5626. menu ID will be negative.) SystemMenu directs the desk accessory to perform the
  5627. appropriate action for the given menu item.
  5628.  
  5629. æKY SystemTask
  5630. æFp Desk.p
  5631. æT PROCEDURE
  5632. æTN $A9B4
  5633. æD PROCEDURE SystemTask;
  5634. æDT SystemTask;
  5635. æRT 85
  5636. æRI SystemTask procedure  I-442, 444, II-189, N85-1
  5637. æC 
  5638. For each open desk accessory (or other device driver performing periodic actions),
  5639. SystemTask causes the accessory to perform the periodic action defined for it, if any
  5640. such action has been defined and if the proper time period has passed since the
  5641. action was last performed. For example, a clock accessory can be defined such that
  5642. the second hand is to move once every second; the periodic action for the accessory
  5643. will be to move the second hand to the next position, and SystemTask will alert the
  5644. accessory every second to perform that action.
  5645.  
  5646. You should call SystemTask as often as possible, usually once every time through your
  5647. main event loop. Call it more than once if your application does an unusually large
  5648. amount of processing each time through the loop.
  5649.  
  5650. Note:  SystemTask should be called at least every sixtieth of a second.
  5651.  
  5652. æKY DeskBus.p
  5653. æKL ADBOp
  5654. ADBReInit
  5655. CountADBs
  5656. GetADBInfo
  5657. GetIndADB
  5658. SetADBInfo
  5659.  
  5660. ADBAddress
  5661. ADBDataBlock
  5662. ADBDBlkPtr
  5663. ADBOpBlock
  5664. ADBOpBPtr
  5665. ADBSetInfoBlock
  5666. ADBSInfoPtr
  5667.  
  5668.  
  5669. æKY ADBAddress
  5670. æFp DeskBus.p
  5671. æT TYPE
  5672. æC ADBAddress = SignedByte;
  5673.  
  5674. æKY ADBDataBlock,ADBDBlkPtr
  5675. æFp DeskBus.p
  5676. æT TYPE
  5677. æC ADBDBlkPtr = ^ADBDataBlock;
  5678. ADBDataBlock = PACKED RECORD
  5679.    devType: SignedByte;        {device type}
  5680.    origADBAddr: SignedByte;    {original ADB Address}
  5681.    dbServiceRtPtr: Ptr;        {service routine pointer}
  5682.    dbDataAreaAddr: Ptr;        {data area address}
  5683.    END;
  5684.  
  5685. æKY ADBOp
  5686. æFp Deskbus.p
  5687. æT FUNCTION
  5688. æTN $A07C
  5689. æD FUNCTION ADBOp(data: Ptr;compRout: ProcPtr;buffer: Ptr;commandNum: INTEGER): OSErr;
  5690. æDT myVariable := ADBOp(data,compRout,buffer,commandNum);
  5691. æRT 206
  5692. æRI ADBOp function  V-368
  5693. æC 
  5694. Trap macro    _ADBOp
  5695.  
  5696. On entry:    A0:  pointer to parameter block
  5697.              D0:  commandNum (byte)
  5698.  
  5699. Parameter block
  5700.     -->    0    buffer      pointer
  5701.     -->    4    compRout    pointer
  5702.     -->    8    data        pointer
  5703.  
  5704. On exit:     D0:  result code (byte)
  5705.  
  5706. The completion routine pointed to by compRout will be passed the following parameters
  5707. on entry:
  5708.  
  5709.              D0:  commandNum (byte)
  5710.              A0:  pointer to buffer, data stored as a Pascal string (maximum
  5711.                   8 bytes data preceded by one length byte)
  5712.              A1:  pointer to completion routine (compRout)
  5713.              A2:  pointer to optional data area (data)
  5714.  
  5715. ADBOp transmits over the bus the command byte whose value is given by commandNum. The
  5716. structure of the command byte is given earlier in Figure 1. ADBOp executes only when
  5717. the ADB is otherwise idle; otherwise it is held in a command queue. It returns an
  5718. error if the command queue is full. The length of the data buffer pointed to by
  5719. buffer is contained in its first byte, like a Pascal string. The optional data area
  5720. pointed to by data is for local storage by the completion routine pointed to by
  5721. compRout. ADBop should be used sparingly; it is not intended for polling a device. 
  5722. The host automatically polls devices with data to deliver.
  5723.  
  5724. Result codes    noErr    No error
  5725.                 –1       Unsuccessful completion
  5726.  
  5727. æKY ADBOpBlock,ADBOpBPtr
  5728. æFp DeskBus.p
  5729. æT TYPE
  5730. æC ADBOpBPtr = ^ADBOpBlock;
  5731. ADBOpBlock = RECORD
  5732.    dataBuffPtr: Ptr;           {address of data buffer}
  5733.    opServiceRtPtr: Ptr;        {service routine pointer}
  5734.    opDataAreaPtr: Ptr;         {optional data area address}
  5735.    END;
  5736.  
  5737. æKY ADBReInit
  5738. æFp Deskbus.p
  5739. æT PROCEDURE
  5740. æTN $A07B
  5741. æD PROCEDURE ADBReInit;
  5742. æDT ADBReInit;
  5743. æMM 
  5744. æRT 143, 206 
  5745. æRI ADBReInit procedure  V-367, N143
  5746. æC 
  5747. Trap macro    _ADBReInit
  5748.  
  5749. ADBReInit reinitializes the entire Apple Desktop Bus. It clears the ADB device table
  5750. to zeros and places a SendReset command on the bus to reset all devices to their
  5751. original addresses. ADBReInit has no parameters.
  5752.  
  5753. Because it does not deallocate ADB resources on the system heap, ADBReInit should not
  5754. be used for routine bus initialization. Apple strongly recommends against adding
  5755. devices while the system is running; therefore, you should never call ADBReInit.
  5756.  
  5757. ADBReInit also calls a routine pointed to by the low memory global JADBProc
  5758. at the beginning and end of its execution.  You can insert your own
  5759. preprocessing/postprocessing routine by changing the value of JADBProc; ADBReInit
  5760. conditions it by setting D0 to 0 for preprocessing and to 1 for postprocessing.  Your
  5761. procedure must restore the value of D0 and branch to the original value of JADBProc
  5762. on exit.  JADBProc should be used to de-allocate memory used by the driver (see
  5763. MacDTS Sample Code “TbltDrvr” for an example), and then it should chain to the procedure
  5764. originally found in JADBProc.
  5765.  
  5766. The complete ADBReInit sequence is therefore the following:
  5767.  
  5768.   •  JSR to JADBProc with D0 set to 0
  5769.   •  reinitialize the Apple Desktop Bus
  5770.   •  clear the ADB device table
  5771.   •  JSR to JADBProc with D0 set to 1
  5772.  
  5773. æKY ADBSetInfoBlock,ADBSInfoPtr
  5774. æFp DeskBus.p
  5775. æT TYPE
  5776. æC ADBSInfoPtr = ^ADBSetInfoBlock;
  5777. ADBSetInfoBlock = RECORD
  5778.    siServiceRtPtr: Ptr;        {service routine pointer}
  5779.    siDataAreaAddr: Ptr;        {data area address}
  5780.    END;
  5781.  
  5782. æKY CountADBs
  5783. æFp Deskbus.p
  5784. æT FUNCTION
  5785. æTN $A077
  5786. æD FUNCTION CountADBs: INTEGER;
  5787. æDT myVariable := CountADBs;
  5788. æRT 206
  5789. æRI CountADBs function  V-369
  5790. æC 
  5791. Trap macro    _CountADBs
  5792.  
  5793. On exit:    D0:  number of devices (byte)
  5794.  
  5795. CountADBs returns a value representing the number of devices connected to the ADB by
  5796. counting the number of entries in the device table. It has no arguments and returns
  5797. no error codes.
  5798.  
  5799. æKY GetADBInfo
  5800. æFp Deskbus.p
  5801. æT FUNCTION
  5802. æTN $A079
  5803. æD FUNCTION GetADBInfo(VAR info: ADBDataBlock;adbAddr: ADBAddress): OSErr;
  5804. æDT myVariable := GetADBInfo(info,adbAddr);
  5805. æRI GetADBInfo function  V-370
  5806. æC 
  5807. Trap macro    _GetADBInfo
  5808.  
  5809. On entry:    A0:  pointer to parameter block
  5810.              D0:  ADB address of the device (byte)
  5811.  
  5812. Parameter block
  5813.     <--    0    device handler ID          byte
  5814.     <--    1    original ADB address       byte
  5815.     <--    2    service routine address    pointer (compRout)
  5816.     <--    6    data area address          pointer (data)
  5817.  
  5818. On exit:     D0:  result code (byte)
  5819.  
  5820. GetADBInfo returns information from the ADB device table entry of the device whose
  5821. ADB address is given by ABDAddr. The structure of ADBDataBlock is given above under
  5822. “GetIndADB”.
  5823.  
  5824. Result codes    noErr    No error
  5825.  
  5826. æKY GetIndADB
  5827. æFp Deskbus.p
  5828. æT FUNCTION
  5829. æTN $A078
  5830. æD FUNCTION GetIndADB(VAR info: ADBDataBlock;devTableIndex: INTEGER): ADBAddress;
  5831. æDT myVariable := GetIndADB(info,devTableIndex);
  5832. æRT 206
  5833. æRI GetIndADB function  V-369
  5834. æC 
  5835. Trap macro    _GetIndADB
  5836.  
  5837. On entry:    A0:  pointer to parameter block
  5838.              D0:  entry index number; range = 1..CountADBs (byte)
  5839.  
  5840. Parameter block
  5841.     <--    0    device type                byte    (handler ID)
  5842.     <--    1    original ADB address       byte
  5843.     <--    2    service routine address    pointer (compRout)
  5844.     <--    6    data area address          pointer (data)
  5845.  
  5846. On exit:     D0:  positive value:  current ADB address (byte)
  5847.                   negative value:  error code (byte)
  5848.  
  5849. GetIndADB returns information from the ADB device table entry whose index number is
  5850. given by devTableIndex. ADBDataBlock has this form:
  5851.  
  5852. TYPE  ADBDataBlock =
  5853.              PACKED RECORD
  5854.                devType:         SignedByte; {device type (handler ID)}
  5855.                origADBAddr:     SignedByte; {original ADB address}
  5856.                dbServiceRtPtr:  Ptr;        {service routine address (compRout)}
  5857.                dbDataAreaAddr:  Ptr         {data area address (data)}
  5858.              END;
  5859.  
  5860. GetIndADB returns the current ADB address of the device. If it is unable to complete
  5861. execution successfully, GetIndADB returns a negative value.
  5862.  
  5863. æKY SetADBInfo
  5864. æFp Deskbus.p
  5865. æT FUNCTION
  5866. æTN $A07A
  5867. æD FUNCTION SetADBInfo(VAR info: ADBSetInfoBlock;adbAddr: ADBAddress): OSErr;
  5868. æDT myVariable := SetADBInfo(info,adbAddr);
  5869. æRT 206
  5870. æRI SetADBInfo function  V-370
  5871. æC 
  5872. Trap macro    _SetADBInfo
  5873.  
  5874. On entry:    A0:  pointer to parameter block
  5875.              D0:  ADB address of the device (byte)
  5876.  
  5877. Parameter block
  5878.     -->    0    service routine address    pointer (compRout)
  5879.     -->    4    data area address          pointer (data)
  5880.  
  5881. On exit:     D0:  result code (byte)
  5882.  
  5883. SetADBInfo sets the service routine address and the data area address in the ADB
  5884. device table entry for the device whose ADB address is given by ABDAddr. ADBSetInfoBlock
  5885. has this form:
  5886.  
  5887. TYPE  ADBSetInfoBlock =
  5888.                RECORD
  5889.                  siServiceRtPtr:  Ptr;  {service routine address (compRout)}
  5890.                  siDataAreaAddr:  Ptr   {data area address (data)}
  5891.                END;
  5892.  
  5893. Result codes    noErr    No error
  5894.  
  5895. Warning:  You should send a Flush command to the device after calling it
  5896.           with SetADBInfo, to prevent it sending old data to the new data
  5897.           area address.
  5898.  
  5899. æKY Devices.p
  5900. æKL CloseDriver
  5901. Control
  5902. GetDCtlEntry
  5903. KillIO
  5904. OpenDriver
  5905. PBControl
  5906. PBKillIO
  5907. PBOpenDriver
  5908. PBStatus
  5909. SetChooserAlert
  5910. Status
  5911.  
  5912. activDev
  5913. AuxDCE
  5914. AuxDCEHandle
  5915. AuxDCEPtr
  5916. buttonMsg
  5917. cdevGenErr
  5918. cdevMemErr
  5919. cdevResErr
  5920. cdevUnset
  5921. chooserID
  5922. clearDev
  5923. closeDev
  5924. Control
  5925. Control
  5926. copyDev
  5927. cutDev
  5928. DCtlEntry
  5929. DCtlHandle
  5930. DCtlPtr
  5931. deactivDev
  5932. deselectMsg
  5933. fillListMsg
  5934. getSelMsg
  5935. hitDev
  5936. initDev
  5937. keyEvtDev
  5938. macDev
  5939. newSelMsg
  5940. nulDev
  5941. pasteDev
  5942. selectMsg
  5943. terminateMsg
  5944. undoDev
  5945. updateDev
  5946.  
  5947. æKY PBOpenDriver
  5948. æFp Devices.p
  5949. æT FUNCTION
  5950. æD FUNCTION PBOpenDriver(paramBlock: ParmBlkPtr): OSErr;
  5951. æDT myVariable := PBOpenDriver(paramBlock);
  5952.  
  5953. æKY activDev
  5954. æFp Devices.p
  5955. æC 
  5956. activDev = 5; {Activate event}
  5957.  
  5958. »The activDev Message
  5959.  
  5960. An activDev message is sent to the cdev on every activate event.  It allows the cdev
  5961. to reset any items that may have changed while the Control Panel was inactive.   It
  5962. also allows the cdev to send things such as “lists activate” messages.
  5963.  
  5964. æKY AuxDCE,AuxDCEPtr,AuxDCEHandle
  5965. æFp Devices.p
  5966. æT TYPE
  5967. æC AuxDCEPtr = ^AuxDCE;
  5968. AuxDCEHandle = ^AuxDCEPtr;
  5969. AuxDCE = PACKED RECORD
  5970.    dCtlDriver: Ptr;
  5971.    dCtlFlags: INTEGER;
  5972.    dCtlQHdr: QHdr;
  5973.    dCtlPosition: LONGINT;
  5974.    dCtlStorage: Handle;
  5975.    dCtlRefNum: INTEGER;
  5976.    dCtlCurTicks: LONGINT;
  5977.    dCtlWindow: GrafPtr;
  5978.    dCtlDelay: INTEGER;
  5979.    dCtlEMask: INTEGER;
  5980.    dCtlMenu: INTEGER;
  5981.    dCtlSlot: Byte;
  5982.    dCtlSlotId: Byte;
  5983.    dCtlDevBase: LONGINT;
  5984.    dCtlOwner: Ptr;
  5985.    dCtlExtDev: Byte;
  5986.    fillByte: Byte;
  5987.    END;
  5988.  
  5989. æKY buttonMsg
  5990. æFp Devices.p
  5991. æC buttonMsg = 19;
  5992.  
  5993. æKY cdevUnset,cdevGenErr,cdevMemErr,cdevResErr
  5994. æFp Devices.p
  5995. æC 
  5996. »CDEV ERROR CHECKING
  5997. _______________________________________________________________________________
  5998.  
  5999. Because a desk accessory may be called into many strange and wonderful situations,
  6000. careful attention must be paid to error checking.  The two most common error conditions
  6001. are missing resources and lack of memory.  Some error reporting and recovery facilities
  6002. have been provided in the Control Panel to help with errors encountered in a cdev.
  6003.  
  6004. Because the Control Panel has no direct information about the cdev, the cdev’s code
  6005. must be able to detect and recover from error conditions on its own.  If the recovery
  6006. cannot be effected the cdev must dispose of any memory it has allocated, and exit
  6007. back to the Control Panel with an error code.
  6008.  
  6009. Following a shutdown, the Control Panel can help report the error condition to the
  6010. user and prevent accidental reentry into the cdev that might result from such things
  6011. as an update event.  A cdev can request three different error reporting mechanisms
  6012. from the Control Panel:
  6013.  
  6014.   •  If a memory error has occured, then, after the cdev has safely shut
  6015.      itself down, it may request the Control Panel to issue an out-of-memory
  6016.      error message and gray out (paint over with the background pattern) the
  6017.      cdev area of the Control Panel window.  It will remain grayed until
  6018.      another cdev is selected.  The Control Panel window itself is not
  6019.      closed since other cdevs may still be able to function in the environment.
  6020.   •  If a resource error is detected, the cdev may request that a
  6021.      can’t-find-needed-resource error message be issued.
  6022.   •  The cdev may display its own error message and then call on the
  6023.      Control Panel to gray its area.
  6024.  
  6025. The Control Panel uses the cdevValue parameter to send status information to the
  6026. cdev, and a proper cdev uses its function value to send information back to the
  6027. Control Panel.  In the absence of errors, the same value passes back and forth: the
  6028. Control Panel puts the last function value it received into cdevValue when it calls
  6029. the cdev; the cdev returns the value it finds there as the function value.  The cdev
  6030. may want to keep a handle to its own storage, in which case passing it as the function
  6031. value ensures its availability, since the Control Panel will pass it back in cdevValue
  6032. at the next call.
  6033.  
  6034. Four constants have been defined for this cdev/Control Panel communication:
  6035.  
  6036. CONST
  6037.   cdevUnset   =     3;    {initial value passed in cdevValue}
  6038.   cdevGenErr  =    -1;    {generic cdev error}
  6039.   cdevMemErr  =     0;    {insufficient memory for cdev execution}
  6040.   cdevResErr  =     1;    {missing resource needed by cdev}
  6041.  
  6042. After the macDev call, the Control Panel sends cdevUnset in cdevValue, so that until
  6043. an error occurs or the cdev uses its function value as a handle, cdevUnset is passed
  6044. back and forth.  If the cdev encounters an error, it should dispose of all handles
  6045. and pointers it has set up, strip the stack back to the same position as a normal
  6046. exit, and return one of the three error codes as the function result.  The Control
  6047. Panel will respond as follows:
  6048.  
  6049.   Function           Message to                     Control Panel Action    
  6050.   Result             Control Panel   
  6051.  
  6052.   cdevGenErr         The cdev has encountered an    Gray out the cdev’s area,
  6053.                      error from which it cannot     send a 0 in cdevValue in
  6054.                      recover, but do not put up     succeeding cdev calls
  6055.                      an error dialog.
  6056.  
  6057.   cdevMemErr         The cdev has determined that   Gray out cdev’s area, put
  6058.                      there is not enough memory to  up error dialog, send a 0
  6059.                      execute; please put up a       in cdevValue in succeeding
  6060.                      memory error dialog.           cdev calls.
  6061.  
  6062.   cdevResErr         The cdev can’t find a needed   Gray out cdev’s area, put
  6063.                      resource; please put up a      up error dialog, send a 0
  6064.                      resource error dialog.         in cdevValue in succeeding
  6065.                                                     cdev calls.
  6066.  
  6067.   all other values,  No error conditions.           Send the value back in
  6068.   either handles                                    cdevValue.
  6069.   or cdevUnset
  6070.  
  6071. The cdev code should check cdevValue at entry.  A 0 means that the Control Panel has
  6072. responded to a cdev error message by shutting down the cdev and displaying an error
  6073. dialog if one was requested.  The cdev should immediately exit.
  6074.  
  6075. Once the Control Panel has responded to an error message from a cdev it will no
  6076. longer respond to any return values until another cdev is launched.
  6077.  
  6078. æKY chooserID
  6079. æFp Devices.p
  6080. æC chooserID = 1;
  6081.  
  6082. æKY clearDev
  6083. æFp Devices.p
  6084. æC clearDev = 13;
  6085.  
  6086. æKY closeDev
  6087. æFp Devices.p
  6088. æC 
  6089. closeDev = 2; {Close yourself}
  6090.  
  6091. »The closeDev Message
  6092.  
  6093. A closeDev message is sent to the cdev when either the Control Panel is closed or the
  6094. user selects another cdev.  When a cdev receives a closeDev message it should dispose
  6095. of any storage it has allocated, including the handle stored in cdevValue, if any.
  6096.  
  6097. æKY CloseDriver
  6098. æFp Devices.p
  6099. æT FUNCTION
  6100. æD FUNCTION CloseDriver(refNum: INTEGER): OSErr;
  6101. æDT myVariable := CloseDriver(refNum);
  6102. æRI CloseDriver function II-178
  6103. æC 
  6104. [Not in ROM]
  6105.  
  6106. CloseDriver closes the device driver having the reference number refNum. Any pending
  6107. I/O is completed, and the memory used by the driver is released.
  6108.  
  6109. Warning:  Before using this command to close a particular driver, refer
  6110.           to the chapter describing the driver for the consequences of
  6111.           closing it.
  6112.  
  6113. Result codes    noErr           No error
  6114.                 badUnitErr      Bad reference number
  6115.                 dRemoveErr      Attempt to remove an open driver
  6116.                 unitEmptyErr    Bad reference number
  6117.  
  6118. æKY Control
  6119. æFp Devices.p
  6120. æT FUNCTION
  6121. æTN $A004
  6122. æD FUNCTION Control(refNum: INTEGER;csCode: INTEGER;csParamPtr: Ptr): OSErr;
  6123. æDT myVariable := Control(refNum,csCode,csParamPtr);
  6124. æMM   
  6125. æRI Control function  high-level II-179 low-level II-186
  6126. æC 
  6127. [Not in ROM]
  6128.  
  6129. Control sends control information to the device driver having the reference number
  6130. refNum. The type of information sent is specified by csCode, and the information
  6131. itself is pointed to by csParamPtr. The values passed in csCode and pointed to by
  6132. csParamPtr depend on the driver being called.
  6133.  
  6134. Result codes    noErr           No error
  6135.                 badUnitErr      Bad reference number
  6136.                 notOpenErr      Driver isn’t open
  6137.                 unitEmptyErr    Bad reference number
  6138.                 controlErr      Driver can’t respond to this Control call
  6139.  
  6140. æKY copyDev
  6141. æFp Devices.p
  6142. æC copyDev = 11;
  6143.  
  6144. æKY cutDev
  6145. æFp Devices.p
  6146. æC cutDev = 10;
  6147.  
  6148. æKY DCtlEntry,DCtlPtr,DCtlHandle
  6149. æFp Devices.p
  6150. æT TYPE
  6151. æC DCtlPtr = ^DCtlEntry;
  6152. DCtlHandle = ^DCtlPtr;
  6153. DCtlEntry = RECORD
  6154.    dCtlDriver: Ptr;
  6155.    dCtlFlags: INTEGER;
  6156.    dCtlQHdr: QHdr;
  6157.    dCtlPosition: LONGINT;
  6158.    dCtlStorage: Handle;
  6159.    dCtlRefNum: INTEGER;
  6160.    dCtlCurTicks: LONGINT;
  6161.    dCtlWindow: WindowPtr;
  6162.    dCtlDelay: INTEGER;
  6163.    dCtlEMask: INTEGER;
  6164.    dCtlMenu: INTEGER;
  6165.    END;
  6166.  
  6167. »Device Control Entry
  6168.  
  6169. The first time a driver is opened, information about it is read into a structure in
  6170. memory called a device control entry. A device control entry contains the header of
  6171. the driver’s I/O queue, the location of the driver’s routines, and other information.
  6172. A device control entry is a 40-byte relocatable block located in the system heap.
  6173. It’s locked while the driver is open, and unlocked while the driver is closed.
  6174.  
  6175. Most of the data in the device control entry is stored and accessed only by the
  6176. Device Manager, but in some cases the driver itself must store into it. The structure
  6177. of a device control entry is shown below; note that the first four words of the
  6178. driver are copied into the dCtlFlags, dCtlDelay, dCtlEMask, and dCtlMenu fields.
  6179.  
  6180. TYPE  DCtlEntry = RECORD
  6181.                     dCtlDriver:    Ptr;        {pointer to ROM driver or }
  6182.                                                { handle to RAM driver}
  6183.                     dCtlFlags:     INTEGER;    {flags}
  6184.                     dCtlQHdr:      QHdr;       {driver I/O queue header}
  6185.                     dCtlPosition:  LONGINT;    {byte position used by Read }
  6186.                                                { and Write calls}
  6187.                     dCtlStorage:   Handle;     {handle to RAM driver's }
  6188.                                                { private storage}
  6189.                     dCtlRefNum:    INTEGER;    {driver reference number}
  6190.                     dCtlCurTicks:  LONGINT;    {used internally}
  6191.                     dCtlWindow:    WindowPtr;  {pointer to driver's window}
  6192.                     dCtlDelay:     INTEGER;    {number of ticks between }
  6193.                                                { periodic actions}
  6194.                     dCtlEMask:     INTEGER;    {desk accessory event mask}
  6195.                     dCtlMenu:      INTEGER     {menu ID of menu associated
  6196.                                                { with driver}
  6197.                   END;
  6198.  
  6199.       DCtlPtr    = ^DCtlEntry;
  6200.       DCtlHandle = ^DCtlPtr;
  6201.  
  6202. The low-order byte of the dCtlFlags word contains the following flags:
  6203.  
  6204. Bit number    Meaning
  6205.  
  6206.     5         Set if driver is open
  6207.     6         Set if driver is RAM-based
  6208.     7         Set if driver is currently executing
  6209.  
  6210. Assembly-language note:  These flags can be accessed with the global
  6211.                          constants dOpened, dRAMBased, and drvrActive.
  6212.  
  6213. The high-order byte of the dCtlFlags word contains flags copied from the drvrFlags
  6214. word of the driver, as described above.
  6215.  
  6216. DCtlQHdr contains the header of the driver’s I/O queue (described below). DCtlPosition
  6217. is used only by drivers of block devices, and indicates the current source or destination
  6218. position of a Read or Write call. The position is given as a number of bytes beyond
  6219. the physical beginning of the medium used by the device. For example, if one logical
  6220. block of data has just been read from a 3 1/2-inch disk via the Disk Driver, dCtlPosition
  6221. will be 512.
  6222.  
  6223. ROM drivers generally use locations in low memory for their local storage. RAM drivers
  6224. may reserve memory within their code space, or allocate a relocatable block and keep
  6225. a handle to it in dCtlStorage (if the block resides in the application heap, its
  6226. handle will be set to NIL when the heap is reinitialized).
  6227.  
  6228. You can get a handle to a driver’s device control entry by calling the Device Manager
  6229. function GetDCtlEntry.
  6230.  
  6231. æKY deactivDev
  6232. æFp Devices.p
  6233. æC 
  6234. deactivDev = 6; {Deactivate event}
  6235.  
  6236. »The deActivDev Message
  6237.  
  6238. A deActivDev message is sent to the cdev on every deactivate event.  It allows the
  6239. cdev to send deactivate messages to items such as lists.
  6240.  
  6241. æKY deselectMsg
  6242. æFp Devices.p
  6243. æC deselectMsg = 16;
  6244.  
  6245. æKY fillListMsg
  6246. æFp Devices.p
  6247. æC fillListMsg = 13;
  6248.  
  6249. æKY GetDCtlEntry
  6250. æFp Devices.p
  6251. æT FUNCTION
  6252. æD FUNCTION GetDCtlEntry(refNum: INTEGER): DCtlHandle;
  6253. æDT myVariable := GetDCtlEntry(refNum);
  6254. æMM 
  6255. æRT 71
  6256. æRI GetDCtlEntry function  II-190
  6257. æC 
  6258. [Not in ROM]
  6259.  
  6260. GetDCtlEntry returns a handle to the device control entry of the device driver having
  6261. the reference number refNum.
  6262.  
  6263. Assembly-language note:  You can get a handle to a driver’s device control
  6264.                          entry from the unit table, as described below.
  6265.  
  6266. æKY getSelMsg
  6267. æFp Devices.p
  6268. æC getSelMsg = 14;
  6269.  
  6270. æKY hitDev
  6271. æFp Devices.p
  6272. æC 
  6273. hitDev = 1; {Hit on one of my items}
  6274.  
  6275. »The hitDev Message
  6276.  
  6277. A hitDev message is sent when the user has clicked an enabled dialog item that belongs
  6278. to the cdev.  The dialog item number of the item hit is passed in the Item parameter.
  6279.  Remember that the Control Panel’s items precede yours, so
  6280. you’ll want (Item – numItems) to determine which of your items was hit.  If the
  6281. Control Panel itself has n items, the first of the cdev’s items will be n+1 in the
  6282. combined dialog item list.  A cdev should not depend on any hardcoded value for
  6283. numItems, since the number of items in Control Panel’s 'DITL' is likely to change in
  6284. the future.
  6285.  
  6286. Factoring in numItems need not mean an increase in your code size, or passing and
  6287. adding numItems everywhere, or foregoing the constants that most developers use to
  6288. identify specific items.  You can do it easily, and neatly, as follows:
  6289.  
  6290.   1.  Subtract numItems from Item right away, and refer to your dialog
  6291.       items with constants as usual throughout the cdev.
  6292.   2.  Write simple envelope routines to enclose Dialog Manager procedures
  6293.       that require item number arguments.  Add numItems only locally,
  6294.       within those routines and for the Dialog Manager calls only.
  6295.  
  6296. This is demonstrated in the sample cdev.
  6297.  
  6298. æKY initDev
  6299. æFp Devices.p
  6300. æC 
  6301. initDev = 0; {Time for cdev to initialize itself}
  6302.  
  6303. »The initDev Message
  6304.  
  6305. InitDev is an initialization message sent to allow the cdev to allocate its private
  6306. storage (if any) and do any initial settings to buttons or controls.  This message is
  6307. sent when the user clicks on the cdev’s icon.
  6308.  
  6309. Note that the dialog, cdev list, and all of the items in the cdev’s 'DITL' except
  6310. user items will already have been drawn when the initDev message is sent.
  6311.  
  6312. If your cdev doesn’t need any storage it should return the value that was passed to
  6313. it in cdevValue.
  6314.  
  6315. æKY keyEvtDev
  6316. æFp Devices.p
  6317. æC 
  6318. keyEvtDev = 7; {Key down/auto key}
  6319.  
  6320. »The keyEvtDev Message
  6321.  
  6322. A keyEvtDev message is sent to the cdev on every keyDown event and autoKey event.  It
  6323. allows the cdev to process key events.  On return to the Control Panel, the key event
  6324. will be processed by a call to dialogSelect in the Dialog Manager.  A cdev that does
  6325. not want the Toolbox Event Manager to do any further processing should change the
  6326. what field of the EventRecord to nullEvent before returning to the Control Panel.
  6327.  
  6328. æKY KillIO
  6329. æFp Devices.p
  6330. æT FUNCTION
  6331. æTN $A006
  6332. æD FUNCTION KillIO(refNum: INTEGER): OSErr;
  6333. æDT myVariable := KillIO(refNum);
  6334. æRI KillIO function high-level II-179 
  6335. æC 
  6336. [Not in ROM]
  6337.  
  6338. KillIO terminates all current and pending I/O with the device driver having the
  6339. reference number refNum.
  6340.  
  6341. Result codes    noErr           No error
  6342.                 badUnitErr      Bad reference number
  6343.                 unitEmptyErr    Bad reference number
  6344.  
  6345. æKY macDev
  6346. æFp Devices.p
  6347. æC 
  6348. macDev = 8; {Decide whether or not to show up}
  6349.  
  6350. »The macDev Message
  6351.  
  6352. If the 'mach' resource has a 0 in Softmask and a –1 ($FFFF) in Hardmask, the first
  6353. message a cdev will get is a macDev message.  This is an opportunity for the cdev to
  6354. determine whether it can run, and whether it should appear in the Control Panel’s
  6355. cdev list.  The cdev can do its own check to see which machine it is being run on,
  6356. what hardware is connected, and what is in the slots (if it has slots).  The cdev
  6357. must then return a function result of 1 or 0.  If  a 0 is returned, the Control Panel
  6358. will not display the cdev in the icon list.  (Note that the Control Panel does not
  6359. interpret this 0 or 1 as an error message as described under “Cdev Error Checking”.)
  6360.  
  6361. The macDev call happens only once, and only when Softmask and Hardmask are 0 and
  6362. FFFF.  It is always the first call made to the cdev.
  6363.  
  6364. æKY newSelMsg
  6365. æFp Devices.p
  6366. æC newSelMsg = 12;
  6367.  
  6368. æKY nulDev
  6369. æFp Devices.p
  6370. æC 
  6371. nulDev = 3; {Null event}
  6372.  
  6373. »The nulDev Message
  6374.  
  6375. A nulDev message is sent to the cdev on every Control Panel run event.  This allows
  6376. the cdev to perform tasks that need to be executed continuously
  6377. (insertion point blinking, for example).
  6378.  
  6379. A cdev cannot assume any particular timing of calls from applications.  Don’t use
  6380. nulDev to refresh settings; see activDev, above.
  6381.  
  6382. æKY OpenDriver
  6383. æFp Devices.p
  6384. æT FUNCTION
  6385. æD FUNCTION OpenDriver(name: Str255;VAR drvrRefNum: INTEGER): OSErr;
  6386. æDT myVariable := OpenDriver(name,drvrRefNum);
  6387. æMM   
  6388. æRI OpenDriver function II-178, N14-2
  6389. æC 
  6390. [Not in ROM]
  6391.  
  6392. OpenDriver opens the device driver specified by name and returns its reference number
  6393. in refNum.
  6394.  
  6395. Result codes    noErr           No error
  6396.                 badUnitErr      Bad reference number
  6397.                 dInstErr        Couldn’t find driver in resource file
  6398.                 openErr         Driver can’t perform the requested
  6399.                                 reading or writing
  6400.                 unitEmptyErr    Bad reference number
  6401.  
  6402. æKY pasteDev
  6403. æFp Devices.p
  6404. æC pasteDev = 12;
  6405.  
  6406. æKY PBControl
  6407. æFp Devices.p
  6408. æT FUNCTION
  6409. æTN $A004
  6410. æD FUNCTION PBControl(paramBlock: ParmBlkPtr;aSync: BOOLEAN): OSErr;
  6411. æDT myVariable := PBControl(paramBlock,aSync);
  6412. æMM   
  6413. æRI PBControl function II-186
  6414. æC 
  6415. Trap macro    _Control
  6416.  
  6417. Parameter block
  6418.   -->    12    ioCompletion  pointer
  6419.   <--    16    ioResult      word
  6420.   -->    22    ioVRefNum     word
  6421.   -->    24    ioRefNum      word
  6422.   -->    26    csCode        word
  6423.   -->    28    csParam       record
  6424.  
  6425. PBControl sends control information to the device driver having the reference number
  6426. ioRefNum; the drive number, if any, is specified by ioVRefNum. The type of information
  6427. sent is specified by csCode, and the information itself begins at csParam. The values
  6428. passed in csCode and csParam depend on the driver being called.
  6429.  
  6430. Result codes    noErr           No error
  6431.                 badUnitErr      Bad reference number
  6432.                 notOpenErr      Driver isn’t open
  6433.                 unitEmptyErr    Bad reference number
  6434.                 controlErr      Driver can’t respond to this Control call
  6435.  
  6436. æKY PBKillIO
  6437. æFp Devices.p
  6438. æT FUNCTION
  6439. æTN $A006
  6440. æD FUNCTION PBKillIO(paramBlock: ParmBlkPtr;aSync: BOOLEAN): OSErr;
  6441. æDT myVariable := PBKillIO(paramBlock,aSync);
  6442. æRI PBKillIO function II-187
  6443. æC 
  6444. Trap macro    _KillIO
  6445.  
  6446. Parameter block
  6447.   -->    12    ioCompletion  pointer
  6448.   <--    16    ioResult      word
  6449.   -->    24    ioRefNum      word
  6450.  
  6451. PBKillIO stops any current I/O request being processed, and removes all pending I/O
  6452. requests from the I/O queue of the device driver having the reference number ioRefNum.
  6453. The completion routine of each pending I/O request is called, with the ioResult field
  6454. of each request equal to the result code abortErr.
  6455.  
  6456. Result codes    noErr           No error
  6457.                 badUnitErr      Bad reference number
  6458.                 unitEmptyErr    Bad reference number
  6459.  
  6460. æKY PBStatus
  6461. æFp Devices.p
  6462. æT FUNCTION
  6463. æTN $A005
  6464. æD FUNCTION PBStatus(paramBlock: ParmBlkPtr;aSync: BOOLEAN): OSErr;
  6465. æDT myVariable := PBStatus(paramBlock,aSync);
  6466. æMM   
  6467. æRI PBStatus function II-186
  6468. æC 
  6469. Trap macro    _Status
  6470.  
  6471. Parameter block
  6472.   -->    12    ioCompletion  pointer
  6473.   <--    16    ioResult      word
  6474.   -->    22    ioVRefNum     word
  6475.   -->    24    ioRefNum      word
  6476.   -->    26    csCode        word
  6477.   <--    28    csParam       record
  6478.  
  6479. PBStatus returns status information about the device driver having the reference
  6480. number ioRefNum; the drive number, if any, is specified by ioVRefNum. The type of
  6481. information returned is specified by csCode, and the information itself begins at
  6482. csParam. The values passed in csCode and csParam depend on the driver being called.
  6483.  
  6484. Result codes    noErr           No error
  6485.                 badUnitErr      Bad reference number
  6486.                 notOpenErr      Driver isn’t open
  6487.                 unitEmptyErr    Bad reference number
  6488.                 statusErr       Driver can’t respond to this Status call
  6489.  
  6490. æKY selectMsg
  6491. æFp Devices.p
  6492. æC selectMsg = 15;
  6493.  
  6494. æKY SetChooserAlert
  6495. æFp Devices.p
  6496. æT FUNCTION
  6497. æD FUNCTION SetChooserAlert(f: BOOLEAN): BOOLEAN;
  6498. æDT myVariable := SetChooserAlert(f);
  6499. æRI SetChooserAlert function  V-431
  6500. æC If f is true, the Chooser will put up the page setup alert; if f is false
  6501. it won’t.  SetChooserAlert returns the original alert state.  The 
  6502. application should restore the original alert state when it exits.
  6503. _____________________________________________________________________________________
  6504. Assembly-language note:  If the psAlert bit of the low-memory global
  6505. HiliteMode is 0 then no page setup alert will be generated. 
  6506. Applications that set or clear this bit must be sure not to affect
  6507. any other bits in the byte and to restore the bit as they leave.
  6508.      
  6509. HiliteMode  equ  $938
  6510. psAlert     equ  6
  6511. bclr        #psAlert,HiliteMode
  6512. bset        #psAlert,HiliteMode
  6513. _____________________________________________________________________________________
  6514.  
  6515. æKY Status
  6516. æFp Devices.p
  6517. æT FUNCTION
  6518. æTN $A005
  6519. æD FUNCTION Status(refNum: INTEGER;csCode: INTEGER;csParamPtr: Ptr): OSErr;
  6520. æDT myVariable := Status(refNum,csCode,csParamPtr);
  6521. æMM   
  6522. æRI Status function  high-level II-179  low-level II-186
  6523. æC 
  6524. [Not in ROM]
  6525.  
  6526. Status returns status information about the device driver having the reference number
  6527. refNum. The type of information returned is specified by csCode, and the information
  6528. itself is pointed to by csParamPtr. The values passed in csCode and pointed to by
  6529. csParamPtr depend on the driver being called.
  6530.  
  6531. Result codes    noErr           No error
  6532.                 badUnitErr      Bad reference number
  6533.                 notOpenErr      Driver isn’t open
  6534.                 unitEmptyErr    Bad reference number
  6535.                 statusErr       Driver can’t respond to this Status call
  6536.  
  6537. æKY terminateMsg
  6538. æFp Devices.p
  6539. æC terminateMsg = 17;
  6540.  
  6541. æKY undoDev
  6542. æFp Devices.p
  6543. æC undoDev = 9;
  6544.  
  6545. æKY updateDev
  6546. æFp Devices.p
  6547. æC 
  6548. updateDev = 4; {Update event}
  6549.  
  6550. »The updateDev Message
  6551.  
  6552. An updateDev message is sent to the cdev on every update event.  It allows the cdev
  6553. to perform any updating necessary aside from the standard dialog item updating provided
  6554. by the Dialog Manager.  For example, if the cdev resource contains a picture of the
  6555. sound control bar, it will probably be a user item, and the picture of the control
  6556. bar and the volume knob should be redrawn in response to update events.
  6557.  
  6558. Note that there is no mechanism for determining what to update, as the update region
  6559. has already been reset.  You must redraw all of your user items completely.
  6560.  
  6561.  
  6562. æKY Dialogs.p
  6563. æKL Alert
  6564. CautionAlert
  6565. CloseDialog
  6566. CouldAlert
  6567. CouldDialog
  6568. DialogSelect
  6569. DisposDialog
  6570. DlgCopy
  6571. DlgCut
  6572. DlgDelete
  6573. DlgPaste
  6574. DrawDialog
  6575. ErrorSound
  6576. FindDItem
  6577. FreeAlert
  6578. FreeDialog
  6579. GetAlrtStage
  6580. GetDItem
  6581. GetIText
  6582. GetNewDialog
  6583. HideDItem
  6584. InitDialogs
  6585. IsDialogEvent
  6586. ModalDialog
  6587. NewCDialog
  6588. NewDialog
  6589. NoteAlert
  6590. ParamText
  6591. ResetAlrtStage
  6592. SelIText
  6593. SetDAFont
  6594. SetDItem
  6595. SetIText
  6596. ShowDItem
  6597. StopAlert
  6598. UpdtDialog
  6599.  
  6600. AlertTemplate
  6601. AlertTHndl
  6602. AlertTPtr
  6603. btnCtrl
  6604. cancel
  6605. cautionIcon
  6606. chkCtrl
  6607. ctrlItem
  6608. DialogPeek
  6609. DialogPtr
  6610. DialogRecord
  6611. DialogTemplate
  6612. DialogTHndl
  6613. DialogTPtr
  6614. editText
  6615. GrafPort
  6616. GrafPtr
  6617. iconItem
  6618. IsDialogEvent
  6619. itemDisable
  6620. noteIcon
  6621. ok
  6622. picItem
  6623. radCtrl
  6624. resCtrl
  6625. StageList
  6626. statText
  6627. stopIcon
  6628. userItem
  6629. WindowPtr
  6630.  
  6631. æKY Alert
  6632. æFp Dialogs.p
  6633. æT FUNCTION
  6634. æTN $A985
  6635. æD FUNCTION Alert(alertID: INTEGER;filterProc: ProcPtr): INTEGER;
  6636. æDT myVariable := Alert(alertID,filterProc);
  6637. æMM   
  6638. æRI Alert function  I-418, V-284
  6639. æC 
  6640. This function invokes the alert defined by the alert template that has the given
  6641. resource ID. It calls the current sound procedure, if any, passing it the sound
  6642. number specified in the alert template for this stage of the alert. If no alert box
  6643. is to be drawn at this stage, Alert returns a function result of –1; otherwise, it
  6644. creates and displays the alert window for this alert and draws the alert box.
  6645.  
  6646. Warning:  If the alert template resource can’t be read, the function result
  6647.           is undefined.
  6648.  
  6649. Note:  Alert creates the alert window by calling NewDialog, and does the
  6650.        rest of its processing by calling ModalDialog.
  6651.  
  6652. Alert repeatedly gets and handles events in the alert window until an enabled item is
  6653. clicked, at which time it returns the item number. Normally you’ll then do whatever
  6654. is appropriate in response to a click of that item.
  6655.  
  6656. Alert gets each event by calling the Toolbox Event Manager function GetNextEvent. If
  6657. the event is a mouse-down event outside the content region of the alert window, Alert
  6658. emits sound number 1 (which should be a single beep) and gets the next event; otherwise,
  6659. it filters and handles the event as described below.
  6660.  
  6661. The filterProc parameter has the same meaning as in ModalDialog (see above). If it’s
  6662. NIL, the standard filterProc function is executed, which makes the Return key or the
  6663. Enter key have the same effect as clicking the default button. If you specify your
  6664. own filterProc function and want to retain this feature, you must include it in your
  6665. function. You can find out what the current default button is by looking at the
  6666. aDefItem field of the dialog record for the alert
  6667. (via the dialog pointer passed to the function).
  6668.  
  6669. Alert handles the events for which the filterProc function returns FALSE as follows:
  6670.  
  6671.   •  If the mouse button is pressed in a control, Alert calls the Control
  6672.      Manager procedure TrackControl. If the mouse button is released inside
  6673.      the control and the control is enabled, Alert returns; otherwise, it
  6674.      does nothing.
  6675.   •  If the mouse button is pressed in any other enabled item, Alert simply
  6676.      returns. If it’s pressed in any other disabled item or in no item, or
  6677.      if any other event occurs, Alert does nothing.
  6678.  
  6679. Before returning to the application with the item number, Alert removes the alert box
  6680. from the screen. (It disposes of the alert window and its associated data structures,
  6681. the item list, and the items.)
  6682.  
  6683. Note:  When an alert is removed, if it was overlapping the default button
  6684.        of a previous alert, that button’s bold outline won’t be redrawn.
  6685.  
  6686. Note:  The Alert function’s removal of the alert box would not be the
  6687.        desired result if the user clicked a check box or radio button;
  6688.        however, normally alerts contain only static text, icons, pictures,
  6689.        and buttons that are supposed to make the alert box go away. If your
  6690.        alert contains other items besides these, consider whether it might
  6691.        be more appropriate as a dialog.
  6692.  
  6693. The Alert function looks for a resource of type 'actb' with the same ID as the alert.
  6694. The alert color table is copied before it is passed to SetWinSize unless its ctSize
  6695. field is equal to –1, indicating that the default window colors are to be used instead.
  6696. The copy is made so that the color table resource can be purged without affecting the
  6697. alert.
  6698.  
  6699. The color dialog item list resource is duplicated as well, so it can be purgeable.
  6700.  
  6701. æKY AlertTemplate,AlertTPtr,AlertTHndl
  6702. æFp Dialogs.p
  6703. æT TYPE
  6704. æC AlertTPtr = ^AlertTemplate;
  6705. AlertTHndl = ^AlertTPtr;
  6706. AlertTemplate = RECORD
  6707.    boundsRect: Rect;
  6708.    itemsID: INTEGER;
  6709.    stages: StageList;
  6710.    END;
  6711.  
  6712. »Alert Templates in Memory
  6713.  
  6714. The data structure of an alert template is as follows:
  6715.  
  6716. TYPE AlertTemplate = RECORD
  6717.                        boundsRect:  Rect;      {becomes window's portRect}
  6718.                        itemsID:     INTEGER;   {resource ID of item list}
  6719.                        stages:      StageList  {alert stage information}
  6720.                      END;
  6721.  
  6722. BoundsRect is the rectangle that becomes the portRect of the window's grafPort. The
  6723. itemsID field contains the resource ID of the item list for the alert.
  6724.  
  6725. The information in the stages field determines exactly what should happen at each
  6726. stage of the alert. It's packed into a word that has the following structure:
  6727.  
  6728. TYPE StageList = PACKED RECORD
  6729.                    boldItm4:  0..1;     {default button item number minus 1}
  6730.                    boxDrwn4:  BOOLEAN;  {TRUE if alert box to be drawn}
  6731.                    sound4:    0..3      {sound number}
  6732.                    boldItm3:  0..1; 
  6733.                    boxDrwn3:  BOOLEAN; 
  6734.                    sound3:    0..3 
  6735.                    boldItm2:  0..1; 
  6736.                    boxDrwn2:  BOOLEAN; 
  6737.                    sound2:    0..3 
  6738.                    boldItm1:  0..1; 
  6739.                    boxDrwn1:  BOOLEAN; 
  6740.                    sound1:    0..3 
  6741.                  END;
  6742.  
  6743. Notice that the information is stored in reverse order—for the fourth stage first,
  6744. and for the first stage last.
  6745.  
  6746. The boldItm field indicates which button should be the default button (and therefore
  6747. boldly outlined in the alert box). If the first two items in the alert’s item list
  6748. are the OK button and the Cancel button, respectively, 0 will refer to the OK button
  6749. and 1 to the Cancel button. The reason for this is that the value of boldItm plus 1
  6750. is interpreted as an item number, and normally items 1 and 2 are the OK and Cancel
  6751. buttons, respectively. Whatever the item having the corresponding item number happens
  6752. to be, a bold rounded-corner rectangle will be drawn outside its display rectangle.
  6753.  
  6754. Note:  When deciding where to place items in an alert box, be sure to allow
  6755.        room for any bold outlines that may be drawn.
  6756.  
  6757. The boxDrwn field is TRUE if the alert box is to be drawn.
  6758.  
  6759. The sound field specifies which sound should be emitted at this stage of the alert,
  6760. with a number from 0 to 3 that’s passed to the current sound procedure. You can call
  6761. ErrorSound to specify your own sound procedure; if you don’t, the standard sound
  6762. procedure will be used (as described earlier in the “Alerts” section).
  6763.  
  6764. You access the alert template by converting the handle returned by the Resource
  6765. Manager to a template handle:
  6766.  
  6767. TYPE  AlertTHndl = ^AlertTPtr;
  6768.       AlertTPtr  = ^AlertTemplate;
  6769.  
  6770. Assembly-language note:  Rather than offsets into the fields of the StageList
  6771.                          data structure, there are masks for accessing the
  6772.                          information stored for an alert stage in a stages
  6773.                          word; they’re listed in the summary at the end of
  6774.                          this chapter.
  6775.  
  6776. æKY ctrlItem,btnCtrl,chkCtrl,radCtrl,resCtrl,statText,editText,iconItem,picItem,userItem,itemDisable
  6777. æFp Dialogs.p
  6778. æC 
  6779.   { Item types }
  6780.  
  6781.   ctrlItem     = 4;    {add to following four constants}
  6782.   btnCtrl      = 0;    {standard button control}
  6783.   chkCtrl      = 1;    {standard check box control}
  6784.   radCtrl      = 2;    {standard radio button control}
  6785.   resCtrl      = 3;    {control defined in control template}
  6786.   statText     = 8;    {static text}
  6787.   editText     = 16;   {editable text (dialog only)}
  6788.   iconItem     = 32;   {icon}
  6789.   picItem      = 64;   {QuickDraw picture}
  6790.   userItem     = 0;    {application-defined item (dialog only)}
  6791.   itemDisable  = 128;  {add to any of above to disable}
  6792.  
  6793. æKY CautionAlert
  6794. æFp Dialogs.p
  6795. æT FUNCTION
  6796. æTN $A988
  6797. æD FUNCTION CautionAlert(alertID: INTEGER;filterProc: ProcPtr): INTEGER;
  6798. æDT myVariable := CautionAlert(alertID,filterProc);
  6799. æMM   
  6800. æRI CautionAlert function I-420
  6801. æC  
  6802. CautionAlert is like StopAlert except that it draws the Caution icon, which has the
  6803. following resource ID:
  6804.  
  6805. CONST cautionIcon = 2;
  6806.  
  6807. The calls CautionAlert, StopAlert, and NoteAlert look for a resource of type
  6808. 'actb' with the same ID as the alert.
  6809.  
  6810. æKY CloseDialog
  6811. æFp Dialogs.p
  6812. æT PROCEDURE
  6813. æTN $A982
  6814. æD PROCEDURE CloseDialog(theDialog: DialogPtr);
  6815. æDT CloseDialog(theDialog);
  6816. æMM   
  6817. æRI CloseDialog procedure I-413, P-107, 167
  6818. æC 
  6819. CloseDialog removes theDialog’s window from the screen and deletes it from the window
  6820. list, just as when the Window Manager procedure CloseWindow is called. It releases
  6821. the memory occupied by the following:
  6822.  
  6823.   •  The data structures associated with the dialog window (such as the
  6824.      window’s structure, content, and update regions).
  6825.   •  All the items in the dialog (except for pictures and icons, which
  6826.      might be shared resources), and any data structures associated with
  6827.      them. For example, it would dispose of the region occupied by the
  6828.      thumb of a scroll bar, or a similar region for some other control
  6829.      in the dialog.
  6830.  
  6831. CloseDialog does not dispose of the dialog record or the item list. Figure 10 illustrates
  6832. the effect of CloseDialog (and DisposDialog, described below).
  6833.  
  6834. •••Refer to Figure 10.•••
  6835.  
  6836. Figure 10–CloseDialog and DisposDialog
  6837.  
  6838. Call CloseDialog when you’re done with a dialog if you supplied NewDialog or GetNewDialog
  6839. with a pointer to the dialog storage (in the dStorage parameter) when you created the
  6840. dialog.
  6841.  
  6842. Note:  Even if you didn’t supply a pointer to the dialog storage, you may
  6843.        want to call CloseDialog if you created the dialog with NewDialog.
  6844.        You would call CloseDialog if you wanted to keep the item list around
  6845.        (since, unlike GetNewDialog, NewDialog does not use a copy of the
  6846.        item list).
  6847.  
  6848. æKY CouldAlert
  6849. æFp Dialogs.p
  6850. æT PROCEDURE
  6851. æTN $A989
  6852. æD PROCEDURE CouldAlert(alertID: INTEGER);
  6853. æDT CouldAlert(alertID);
  6854. æMM   
  6855. æRI CouldAlert procedure I-420, V-285
  6856. æC 
  6857. CouldAlert makes the alert template having the given resource ID unpurgeable
  6858. (reading it into memory if it’s not already there). It does the same for the alert
  6859. window’s definition function, the alert’s item list resource, and any items defined
  6860. as resources. This is useful if the alert may occur when the resource file isn’t
  6861. accessible, such as during a disk copy.
  6862.  
  6863. Warning:  Like CouldDialog, CouldAlert assumes your alerts use the system
  6864.           font; if you’ve changed the font with SetDAFont, calling CouldAlert
  6865.           doesn’t make the font unpurgeable.
  6866.  
  6867. The CouldAlert routine makes the alert color table template unpurgeable
  6868. (reading it into memory if it isn’t already there), if it exists. It does the same
  6869. for the alert’s color item list, if it has one.
  6870.  
  6871. Warning:  Like CouldDialog, CouldAlert doesn’t load or make 'FONT' or
  6872.           'FOND' resources indicated in the color item list unpurgeable.
  6873.  
  6874. æKY CouldDialog
  6875. æFp Dialogs.p
  6876. æT PROCEDURE
  6877. æTN $A979
  6878. æD PROCEDURE CouldDialog(dialogID: INTEGER);
  6879. æDT CouldDialog(dialogID);
  6880. æMM   
  6881. æRI CouldDialog procedure I-415, V-284
  6882. æC 
  6883. CouldDialog makes the dialog template having the given resource ID unpurgeable
  6884. (reading it into memory if it’s not already there). It does the same for the dialog
  6885. window’s definition function, the dialog’s item list resource, and any items defined
  6886. as resources. This is useful if the dialog box may come up when the resource file
  6887. isn’t accessible, such as during a disk copy.
  6888.  
  6889. Warning:  CouldDialog assumes your dialogs use the system font; if you’ve
  6890.           changed the font with SetDAFont, calling CouldDialog doesn’t make
  6891.           the font unpurgeable.
  6892.  
  6893. The CouldDialog procedure makes the dialog color table template unpurgeable
  6894. (reading it into memory if it isn’t already there), if it exists. It does the same
  6895. for the dialog’s color item list, if it has one.
  6896.  
  6897. Warning:  CouldDialog doesn’t load or make 'FONT' or 'FOND' resources
  6898.           indicated in the color item list unpurgeable.
  6899.  
  6900. æKY DialogPtr,WindowPtr,GrafPtr,GrafPort
  6901. æFp Dialogs.p
  6902. æT TYPE
  6903. æC GrafPtr = ^GrafPort;
  6904. WindowPtr = GrafPtr;
  6905. DialogPtr = WindowPtr;
  6906. GrafPort = RECORD
  6907.    device: INTEGER;
  6908.    portBits: BitMap;
  6909.    portRect: Rect;
  6910.    visRgn: RgnHandle;
  6911.    clipRgn: RgnHandle;
  6912.    bkPat: Pattern;
  6913.    fillPat: Pattern;
  6914.    pnLoc: Point;
  6915.    pnSize: Point;
  6916.    pnMode: INTEGER;
  6917.    pnPat: Pattern;
  6918.    pnVis: INTEGER;
  6919.    txFont: INTEGER;
  6920.    txFace: Style;                          {txFace is unpacked byte but push as short}
  6921.    txMode: INTEGER;
  6922.    txSize: INTEGER;
  6923.    spExtra: Fixed;
  6924.    fgColor: LONGINT;
  6925.    bkColor: LONGINT;
  6926.    colrBit: INTEGER;
  6927.    patStretch: INTEGER;
  6928.    picSave: Handle;
  6929.    rgnSave: Handle;
  6930.    polySave: Handle;
  6931.    grafProcs: QDProcsPtr;
  6932.    END;
  6933. »Dialog Pointers
  6934.  
  6935. There are two types of dialog pointer, DialogPtr and DialogPeek, analogous to the
  6936. window pointer types WindowPtr and WindowPeek. Most programmers will only need to use
  6937. DialogPtr.
  6938.  
  6939. The Dialog Manager defines the following type of dialog pointer:
  6940.  
  6941. TYPE  DialogPtr = WindowPtr;
  6942.  
  6943. It can do this because the first field of a dialog record contains the window record
  6944. for the dialog window. This type of pointer can be used to access fields of the
  6945. window record or can be passed to Window Manager routines that expect window pointers
  6946. as parameters. Since the WindowPtr data type is itself defined as GrafPtr, this type
  6947. of dialog pointer can also be used to access fields of the dialog window’s grafPort
  6948. or passed to QuickDraw routines that expect pointers to grafPorts as parameters.
  6949.  
  6950. For programmers who want to access dialog record fields beyond the window record, the
  6951. Dialog Manager also defines the following type of dialog pointer:
  6952.  
  6953. TYPE  DialogPeek = ^DialogRecord;
  6954.  
  6955. Assembly-language note:  From assembly language, of course, there’s no
  6956.                          type checking on pointers, and the two types
  6957.                          of pointer are equal.
  6958.  
  6959. _______________________________________________________________________________
  6960.  
  6961. »The DialogRecord Data Type
  6962.  
  6963. For those who want to know more about the data structure of a dialog record, the
  6964. exact structure is given here.
  6965.  
  6966. TYPE  DialogRecord = RECORD
  6967.                        window:     WindowRecord;  {dialog window}
  6968.                        items:      Handle;        {item list}
  6969.                        textH:      TEHandle;      {current editText item}
  6970.                        editField:  INTEGER;       {editText item number minus 1}
  6971.                        editOpen:   INTEGER;       {used internally}
  6972.                        aDefItem:   INTEGER        {default button item number}
  6973.                      END;
  6974.  
  6975. The window field contains the window record for the dialog window. The items field
  6976. contains a handle to the item list used for the dialog. (Remember that after reading
  6977. an item list from a resource file, the Dialog Manager makes a copy of it and uses
  6978. that copy.)
  6979.  
  6980. Note:  To get or change information about an item in a dialog, you pass the
  6981.        dialog pointer and the item number to a Dialog Manager procedure.
  6982.        You’ll never access information directly through the handle to the
  6983.        item list.
  6984.  
  6985. The Dialog Manager uses the next three fields when there are one or more editText
  6986. items in the dialog. If there’s more than one such item, these fields apply to the
  6987. one that currently is selected or displays the insertion point. The textH field
  6988. contains the handle to the edit record used by TextEdit. EditField is 1 less than the
  6989. item number of the current editText item, or –1 if there’s no editText item in the
  6990. dialog. The editOpen field is used internally by the Dialog Manager.
  6991.  
  6992. Note:  Actually, a single edit record is shared by all editText items; any
  6993.        changes you make to it will apply to all such items. See the TextEdit
  6994.        chapter for details about what kinds of changes you can make.
  6995.  
  6996. The aDefItem field is used for modal dialogs and alerts, which are treated internally
  6997. as special modal dialogs. It contains the item number of the default button. The
  6998. default button for a modal dialog is the first item in the item list, so this field
  6999. contains 1 for modal dialogs. The default button for an alert is specified in the
  7000. alert template; see the following section for more information.
  7001.  
  7002. _______________________________________________________________________________
  7003.  
  7004. »THE DRAWING ENVIRONMENT:  GRAFPORT
  7005. _______________________________________________________________________________
  7006.  
  7007. A grafPort is a complete drawing environment that defines where and how graphic
  7008. operations will take place. You can have many grafPorts open at once, and each one
  7009. will have its own coordinate system, drawing pattern, background pattern, pen size
  7010. and location, character font and style, and bit map in which drawing takes place. You
  7011. can instantly switch from one port to another. GrafPorts are the structures upon
  7012. which a program builds windows, which are fundamental to the Macintosh “overlapping
  7013. windows” user interface. Besides being used for windows on the screen, grafPorts are
  7014. used for printing and for off-screen drawing.
  7015.  
  7016. A grafPort is defined as follows:
  7017.  
  7018. TYPE  GrafPtr   =  ^GrafPort;
  7019.       GrafPort  =  RECORD
  7020.                      device:      INTEGER;    {device-specific information}
  7021.                      portBits:    BitMap;     {grafPort's bit map}
  7022.                      portRect:    Rect;       {grafPort's rectangle}
  7023.                      visRgn:      RgnHandle;  {visible region}
  7024.                      clipRgn:     RgnHandle;  {clipping region}
  7025.                      bkPat:       Pattern;    {background pattern}
  7026.                      fillPat:     Pattern;    {fill pattern}
  7027.                      pnLoc:       Point;      {pen location}
  7028.                      pnSize:      Point;      {pen size}
  7029.                      pnMode:      INTEGER;    {pen's transfer mode}
  7030.                      pnPat:       Pattern;    {pen pattern}
  7031.                      pnVis:       INTEGER;    {pen visibility}
  7032.                      txFont:      INTEGER;    {font number for text}
  7033.                      txFace:      Style;      {text's character style}
  7034.                      txMode:      INTEGER;    {text's transfer mode}
  7035.                      txSize:      INTEGER;    {font size for text}
  7036.                      spExtra:     Fixed;      {extra space}
  7037.                      fgColor:     LONGINT;    {foreground color}
  7038.                      bkColor:     LONGINT;    {background color}
  7039.                      colrBit:     INTEGER;    {color bit}
  7040.                      patStretch:  INTEGER;    {used internally}
  7041.                      picSave:     Handle;     {picture being saved}
  7042.                      rgnSave:     Handle;     {region being saved}
  7043.                      polySave:    Handle;     {polygon being saved}
  7044.                      grafProcs:   QDProcsPtr  {low-level drawing routines}
  7045.                    END;
  7046.  
  7047. Note that picSave is a Handle used internally by QuickDraw while it is saving a
  7048. picture, and rgnSave and polySave are used by QuickDraw as flags; they are set to “1”
  7049. when the corresponding action is taking place.
  7050.  
  7051. All QuickDraw operations refer to grafPorts via grafPtrs. (For historical reasons,
  7052. grafPort is one of the few objects in the Macintosh system software that’s referred
  7053. to by a pointer rather than a handle.)
  7054.  
  7055. Warning:  You can access all fields and subfields of a grafPort normally,
  7056.           but you should not store new values directly into them. QuickDraw
  7057.           has routines for altering all fields of a grafPort, and using
  7058.           these routines ensures that changing a grafPort produces no
  7059.           unusual side effects.
  7060.  
  7061. The device field of a grafPort contains device-specific information that’s used by
  7062. the Font Manager to achieve the best possible results when drawing text in the grafPort.
  7063. There may be physical differences in the same logical font for different output
  7064. devices, to ensure the highest-quality printing on the device being used. The default
  7065. value of the device field is 0, for best results on output to the screen. For more
  7066. information, see the Font Manager chapter.
  7067.  
  7068. The portBits field is the bit map that points to the bit image to be used by the
  7069. grafPort. The default bit map uses the entire screen as its bit image. The bit map
  7070. may be changed to indicate a different structure in memory:  All graphics routines
  7071. work in exactly the same way regardless of whether their effects are visible on the
  7072. screen. A program can, for example, prepare an image to be printed on a printer
  7073. without ever displaying the image on the screen, or develop a picture in an off-screen
  7074. bit map before transferring it to the screen. The portBits.bounds rectangle determines
  7075. the coordinate system of the grafPort; all other coordinates in the grafPort are
  7076. expressed in this system.
  7077.  
  7078. The portRect field is a rectangle that defines a subset of the bit map that will be
  7079. used for drawing:  All drawing done by the application occurs inside the portRect.
  7080. Its coordinates are in the coordinate system defined by the portBits.bounds rectangle.
  7081. The portRect usually falls within the portBits.bounds rectangle, but it’s not required
  7082. to do so. The portRect usually defines the “writable” interior area of a window,
  7083. document, or other object on the screen.
  7084.  
  7085. The visRgn field is manipulated by the Window Manager; you will normally never change
  7086. a grafPort’s visRgn. It indicates the region of the grafPort that’s actually visible
  7087. on the screen, that is, the part of the window that’s not covered by other windows.
  7088. For example, if you move one window in front of another, the Window Manager logically
  7089. removes the area of overlap from the visRgn of the window in back. When you draw into
  7090. the back window, whatever’s being drawn is clipped to the visRgn so that it doesn’t
  7091. run over onto the front window. The default visRgn is set to the portRect.
  7092.  
  7093. The clipRgn is the grafPort’s clipping region, an arbitrary region that you can use
  7094. to limit drawing to any region within the portRect. If, for example, you want to draw
  7095. a half circle on the screen, you can set the clipRgn to half the square that would
  7096. enclose the whole circle, and then draw the whole circle. Only the half within the
  7097. clipRgn will actually be drawn in the grafPort. The default clipRgn is set arbitrarily
  7098. large, you have full control over its setting; as a matter of recommended programming
  7099. practice, it is advisable to make the default clipRgn rectangle smaller.
  7100.  
  7101. Figure 10 illustrates a typical bit map (as defined by portBits), portRect, visRgn,
  7102. and clipRgn.
  7103.  
  7104. •••Refer to Figure 10.•••
  7105.  
  7106. Figure 10–GrafPort Regions
  7107.  
  7108. The bkPat and fillPat fields of a grafPort contain patterns used by certain QuickDraw
  7109. routines. BkPat is the “background” pattern that’s used when an area is erased or
  7110. when bits are scrolled out of it. When asked to fill an area with a specified pattern,
  7111. QuickDraw stores the given pattern in the fillPat field and then calls a low-level
  7112. drawing routine that gets the pattern from that field. The various graphic operations
  7113. are discussed in detail later in the descriptions of individual QuickDraw routines.
  7114.  
  7115. Of the next ten fields, the first five determine characteristics of the graphics pen
  7116. and the last five determine characteristics of any text that may be drawn; these are
  7117. described in separate sections below.
  7118.  
  7119. The fgColor, bkColor, and colrBit fields contain values related to drawing in color.
  7120. FgColor is the grafPort’s foreground color and bkColor is its background color.
  7121. ColrBit tells the color imaging software which plane of the color picture to draw
  7122. into. For more information, see “Drawing in Color” in the section “General Discussion
  7123. of Drawing”.
  7124.  
  7125. The patStretch field is used during output to a printer to expand patterns if necessary.
  7126. The application should not change its value.
  7127.  
  7128. The picSave, rgnSave, and polySave fields reflect the state of picture, region, and
  7129. polygon definition, respectively. The application shouldn’t be concerned about exactly
  7130. what information the handle, if any, leads to; you may, however, save the current
  7131. value of rgnSave, set the field to NIL to disable the region definition, and later
  7132. restore it to the saved value to resume the region definition. The picSave and polySave
  7133. fields work similarly for pictures and polygons.
  7134.  
  7135. Finally, the grafProcs field may point to a special data structure that the application
  7136. stores into if it wants to customize QuickDraw drawing routines or use QuickDraw in
  7137. other advanced, highly specialized ways (see “Customizing QuickDraw Operations”). If
  7138. grafProcs is NIL, QuickDraw responds in the standard ways described in this chapter.
  7139.  
  7140. _______________________________________________________________________________
  7141.  
  7142. »Pen Characteristics
  7143.  
  7144. The pnLoc, pnSize, pnMode, pnPat, and pnVis fields of a grafPort deal with the graphics
  7145. “pen”. Each grafPort has one and only one such pen, which is used for drawing lines,
  7146. shapes, and text. The pen has four characteristics:  a location, a size (height and
  7147. width), a drawing mode, and a drawing pattern (see Figure
  7148. 11).
  7149.  
  7150. •••Refer to Figure 11.•••
  7151.  
  7152. Figure 11–A Graphics Pen
  7153.  
  7154. The pnLoc field specifies the point where QuickDraw will begin drawing the next line,
  7155. shape, or character. It can be anywhere on the coordinate plane:  There are no restrictions
  7156. on the movement or placement of the pen. Remember that the pen location is a point in
  7157. the grafPort’s coordinate system, not a pixel in a bit image. The top left corner of
  7158. the pen is at the pen location; the pen hangs below and to the right of this point.
  7159.  
  7160. The pen is rectangular in shape, and its width and height are specified by pnSize.
  7161. The default size is a 1-by-1-bit square; the width and height can range from (0,0) to
  7162. (30000,30000). If either the pen width or the pen height is less than 1, the pen will
  7163. not draw.
  7164.  
  7165. The pnMode and pnPat fields of a grafPort determine how the bits under the pen are
  7166. affected when lines or shapes are drawn. The pnPat is a pattern that’s used like the
  7167. “ink” in the pen. This pattern, like all other patterns drawn in the grafPort, is
  7168. always aligned with the port’s coordinate system:  The top left corner of the pattern
  7169. is aligned with the top left corner of the portRect, so that adjacent areas of the
  7170. same pattern will blend into a continuous, coordinated pattern.
  7171.  
  7172. The pnMode field determines how the pen pattern is to affect what’s already in the
  7173. bit image when lines or shapes are drawn. When the pen draws, QuickDraw first determines
  7174. what bits in the bit image will be affected and finds their corresponding bits in the
  7175. pattern. It then does a bit-by-bit comparison based on the pen mode, which specifies
  7176. one of eight Boolean operations to perform. The resulting bit is stored into its
  7177. proper place in the bit image. The pen modes are described under “Transfer Modes” in
  7178. the section “General Discussion of Drawing”.
  7179.  
  7180. The pnVis field determines the pen’s visibility, that is, whether it draws on the
  7181. screen. For more information, see the descriptions of HidePen and ShowPen under “Pen
  7182. and Line-Drawing Routines” in the “QuickDraw Routines” section.
  7183.  
  7184. _______________________________________________________________________________
  7185.  
  7186. »Text Characteristics
  7187.  
  7188. The txFont, txFace, txMode, txSize, and spExtra fields of a grafPort determine how
  7189. text will be drawn—the font, style, and size of characters and how they will be
  7190. placed in the bit image. QuickDraw can draw characters as quickly and easily as it
  7191. draws lines and shapes, and in many prepared fonts. Font means the complete set of
  7192. characters of one typeface. The characters may be drawn in any size and character
  7193. style (that is, with stylistic variations such as bold, italic, and underline).
  7194. Figure 12 shows two characters drawn by QuickDraw and some terms associated with
  7195. drawing text.
  7196.  
  7197. •••Refer to Figure 12.•••
  7198.  
  7199. Figure 12–QuickDraw Characters
  7200.  
  7201. Text is drawn with the base line positioned at the pen location.
  7202.  
  7203. The txFont field is a font number that identifies the character font to be used in
  7204. the grafPort. The font number 0 represents the system font. For more information
  7205. about the system font, the other font numbers recognized by the Font Manager, and the
  7206. construction, layout, and loading of fonts, see the Font Manager chapter.
  7207.  
  7208. A character font is defined as a collection of images that make up the individual
  7209. characters of the font. The characters can be of unequal widths, and they’re not
  7210. restricted to their “cells”:  The lower curl of a lowercase j, for example, can
  7211. stretch back under the previous character (typographers call this kerning). A font
  7212. can consist of up to 255 distinct characters, yet not all characters need to be
  7213. defined in a single font. In addition, each font contains a missing symbol to be
  7214. drawn in case of a request to draw a character that’s missing from the font.
  7215.  
  7216. The txFace field controls the character style of the text with values from the set
  7217. defined by the Style data type:
  7218.  
  7219. TYPE  StyleItem  = (bold,italic,underline,outline,shadow,condense,extend);
  7220.       Style      = SET OF StyleItem;
  7221.  
  7222. Assembly-language note:  In assembly language, this set is stored as a word
  7223.                          whose low-order byte contains bits representing the
  7224.                          style. The bit numbers are specified by the following
  7225.                          global constants:
  7226.  
  7227.                            boldBit       .EQU    0
  7228.                            italicBit     .EQU    1
  7229.                            ulineBit      .EQU    2
  7230.                            outlineBit    .EQU    3
  7231.                            shadowBit     .EQU    5
  7232.                            extendBit     .EQU    6
  7233.  
  7234.                          If all bits are 0, it represents the plain character
  7235.                          style.
  7236.  
  7237. You can apply stylistic variations either alone or in combination; Figure 13 illustrates
  7238. some as applied to the Geneva font. Most combinations usually look good only for
  7239. large font sizes.
  7240.  
  7241. •••Refer to Figure 13.•••
  7242.  
  7243. Figure 13–Stylistic Variations
  7244.  
  7245. If you specify bold, each character is repeatedly drawn one bit to the right an
  7246. appropriate number of times for extra thickness.
  7247.  
  7248. Italic adds an italic slant to the characters. Character bits above the base line are
  7249. skewed right; bits below the base line are skewed left.
  7250.  
  7251. Underline draws a line below the base line of the characters. If part of a character
  7252. descends below the base line (as “y” in Figure 13), the underline
  7253. isn’t drawn through the pixel on either side of the descending part.
  7254.  
  7255. Outline makes a hollow, outlined character rather than a solid one. Shadow also makes
  7256. an outlined character, but the outline is thickened below and to the right of the
  7257. character to achieve the effect of a shadow. If you specify bold along with outline
  7258. or shadow, the hollow part of the character is widened.
  7259.  
  7260. Condense and extend affect the horizontal distance between all characters, including
  7261. spaces. Condense decreases the distance between characters and extend increases it,
  7262. by an amount that the Font Manager determines is appropriate.
  7263.  
  7264. The txMode field controls the way characters are placed in the bit image. It functions
  7265. much like a pnMode:  When a character is drawn, QuickDraw determines which bits in
  7266. the bit image will be affected, does a bit-by-bit comparison based on the mode, and
  7267. stores the resulting bits into the bit image. These modes are described under “Transfer
  7268. Modes” in the section “General Discussion of Drawing”. Only three of them—srcOr,
  7269. srcXor, and srcBic—should be used for drawing text.
  7270.  
  7271. Note:  If you use scrCopy, some extra blank space will be appended at the
  7272.        end of the text.
  7273.  
  7274. The txSize field specifies the font size in points (where “point” is a typographical
  7275. term meaning approximately 1/72 inch). Any size from 1 to 127 points may be specified.
  7276. If the Font Manager doesn’t have the font in a specified size, it will scale a size
  7277. it does have as necessary to produce the size desired. A value of 0 in this field
  7278. represents the system font size (12 points).
  7279.  
  7280. Finally, the spExtra field is useful when a line of characters is to be drawn justified
  7281. such that it’s aligned with both a left and a right margin (sometimes called “full
  7282. justification”). SpExtra contains a fixed-point number equal to the average number of
  7283. pixels by which each space character should be widened to fill out the line. The
  7284. Fixed data type is described in the Macintosh Memory Management:  An Introduction
  7285. chapter.
  7286.  
  7287. _______________________________________________________________________________
  7288.  
  7289. »COORDINATES IN GRAFPORTS
  7290. _______________________________________________________________________________
  7291.  
  7292. Each grafPort has its own local coordinate system. All fields in the grafPort are
  7293. expressed in these coordinates, and all calculations and actions performed in QuickDraw
  7294. use the local coordinate system of the currently selected port.
  7295.  
  7296. Two things are important to remember:
  7297.  
  7298.   •  Each grafPort maps a portion of the coordinate plane into a similarly-
  7299.      sized portion of a bit image.
  7300.   •  The portBits.bounds rectangle defines the local coordinates for a grafPort.
  7301.  
  7302. The top left corner of portBits.bounds is always aligned around the first bit in the
  7303. bit image; the coordinates of that corner “anchor” a point on the grid to that bit in
  7304. the bit image. This forms a common reference point for multiple grafPorts that use
  7305. the same bit image (such as the screen); given a portBits.bounds rectangle for each
  7306. port, you know that their top left corners coincide.
  7307.  
  7308. The relationship between the portBits.bounds and portRect rectangles is very important:
  7309.  The portBits.bounds rectangle establishes a coordinate system for the port, and the
  7310. portRect rectangle indicates the section of the coordinate plane (and thus the bit
  7311. image) that will be used for drawing. The portRect usually falls inside the portBits.bounds
  7312. rectangle, but it’s not required to do so.
  7313.  
  7314. When a new grafPort is created, its bit map is set to point to the entire screen, and
  7315. both the portBits.bounds and the portRect are set to rectangles enclosing the screen.
  7316. The point (0,0) corresponds to the screen’s top left corner.
  7317.  
  7318. You can redefine the local coordinates of the top left corner of the grafPort’s
  7319. portRect, using the SetOrigin procedure. This offsets the coordinates of the grafPort’s
  7320. portBits.bounds rectangle, recalculating the coordinates of all points in the grafPort
  7321. to be relative to the new corner coordinates. For example, consider these procedure
  7322. calls:
  7323.  
  7324.   SetPort(gamePort);
  7325.   SetOrigin(90,80)
  7326.  
  7327. The call to SetPort sets the current grafPort to gamePort; the call to SetOrigin
  7328. changes the local coordinates of the top left corner of that port’s portRect to
  7329. (90,80) (see Figure 14).
  7330.  
  7331. •••Refer to Figure 14.•••
  7332.  
  7333. Figure 14–Changing Local Coordinates
  7334.  
  7335. This offsets the coordinates of the following elements:
  7336.  
  7337.   gamePort^.portBits.bounds
  7338.   gamePort^.portRect
  7339.   gamePort^.visRgn
  7340.  
  7341. These three elements are always kept “in sync”.
  7342.  
  7343. Notice that when the local coordinates of a grafPort are offset, the grafPort’s
  7344. clipRgn and pen location are not offset. A good way to think of it is that the port’s
  7345. structure “sticks” to the screen, while the document in the grafPort
  7346. (along with the pen and clipRgn) “sticks” to the coordinate system. For example, in
  7347. Figure 14, before SetOrigin, the visRgn and clipRgn are the same as the portRect.
  7348. After the SetOrigin call, the locations of portBits.bounds, portRect, and visRgn do
  7349. not change on the screen; their coordinates are simply offset. As always, the top
  7350. left corner of portBits.bounds remains “anchored” around the first bit in the bit
  7351. image (the first pixel on the screen); the image on the screen doesn’t move as a
  7352. result of SetOrigin. However, the pen location and clipRgn do move on the screen; the
  7353. top left corner of the clipRgn is still
  7354. (100,100), but this location has moved down and to the right, and the pen has similarly
  7355. moved.
  7356.  
  7357. If you’re moving, comparing, or otherwise dealing with mathematical items in different
  7358. grafPorts (for example, finding the intersection of two regions in two different
  7359. grafPorts), you must adjust to a common coordinate system before you perform the
  7360. operation. A QuickDraw procedure, LocalToGlobal, lets you convert a point’s local
  7361. coordinates to a global coordinate system where the top left corner of the bit image
  7362. is (0,0); by converting the various local coordinates to global coordinates, you can
  7363. compare and mix them with confidence. For more information, see the description of
  7364. LocaltoGlobal under “Calculations with Points” in the “QuickDraw Routines” section.
  7365.  
  7366. æKY DialogRecord,DialogPeek
  7367. æFp Dialogs.p
  7368. æT RECORD
  7369. æC DialogPeek = ^DialogRecord;
  7370. DialogRecord = RECORD
  7371.    window: WindowRecord;
  7372.    items: Handle;
  7373.    textH: TEHandle;
  7374.    editField: INTEGER;
  7375.    editOpen: INTEGER;
  7376.    aDefItem: INTEGER;
  7377.    END;
  7378.  
  7379. »The DialogRecord Data Type
  7380.  
  7381. For those who want to know more about the data structure of a dialog record, the
  7382. exact structure is given here.
  7383.  
  7384. TYPE  DialogRecord = RECORD
  7385.                        window:     WindowRecord;  {dialog window}
  7386.                        items:      Handle;        {item list}
  7387.                        textH:      TEHandle;      {current editText item}
  7388.                        editField:  INTEGER;       {editText item number minus 1}
  7389.                        editOpen:   INTEGER;       {used internally}
  7390.                        aDefItem:   INTEGER        {default button item number}
  7391.                      END;
  7392.  
  7393. The window field contains the window record for the dialog window. The items field
  7394. contains a handle to the item list used for the dialog. (Remember that after reading
  7395. an item list from a resource file, the Dialog Manager makes a copy of it and uses
  7396. that copy.)
  7397.  
  7398. Note:  To get or change information about an item in a dialog, you pass the
  7399.        dialog pointer and the item number to a Dialog Manager procedure.
  7400.        You’ll never access information directly through the handle to the
  7401.        item list.
  7402.  
  7403. The Dialog Manager uses the next three fields when there are one or more editText
  7404. items in the dialog. If there’s more than one such item, these fields apply to the
  7405. one that currently is selected or displays the insertion point. The textH field
  7406. contains the handle to the edit record used by TextEdit. EditField is 1 less than the
  7407. item number of the current editText item, or –1 if there’s no editText item in the
  7408. dialog. The editOpen field is used internally by the Dialog Manager.
  7409.  
  7410. Note:  Actually, a single edit record is shared by all editText items; any
  7411.        changes you make to it will apply to all such items. See the TextEdit
  7412.        chapter for details about what kinds of changes you can make.
  7413.  
  7414. The aDefItem field is used for modal dialogs and alerts, which are treated internally
  7415. as special modal dialogs. It contains the item number of the default button. The
  7416. default button for a modal dialog is the first item in the item list, so this field
  7417. contains 1 for modal dialogs. The default button for an alert is specified in the
  7418. alert template; see the following section for more information.
  7419.  
  7420.  
  7421. æKY DialogSelect
  7422. æFp Dialogs.p
  7423. æT FUNCTION
  7424. æTN $A980
  7425. æD FUNCTION DialogSelect(theEvent: EventRecord;VAR theDialog: DialogPtr;
  7426.     VAR itemHit: INTEGER): BOOLEAN;
  7427. æDT myVariable := DialogSelect(theEvent,theDialog,itemHit);
  7428. æMM 
  7429. æRT 34
  7430. æRI DialogSelect function I-417, N34-3, P-108, 168
  7431. æC 
  7432. You’ll normally call DialogSelect when IsDialogEvent returns TRUE, passing in theEvent
  7433. an event that needs to be handled as part of a modeless dialog. DialogSelect handles
  7434. the event as described below. If the event involves an enabled dialog item, DialogSelect
  7435. returns a function result of TRUE with the dialog pointer in theDialog and the item
  7436. number in itemHit; otherwise, it returns FALSE with theDialog and itemHit undefined.
  7437. Normally when DialogSelect returns TRUE, you’ll do whatever is appropriate as a
  7438. response to the event, and when it returns FALSE you’ll do nothing.
  7439.  
  7440. If the event is an activate or update event for a dialog window, DialogSelect activates
  7441. or updates the window and returns FALSE.
  7442.  
  7443. If the event is a mouse-down event in an editText item, DialogSelect responds as
  7444. appropriate (displaying a caret at the insertion point or selecting text). If it’s a
  7445. key-down or auto-key event and there’s an editText item, text entry and editing are
  7446. handled in the standard way. In either case, DialogSelect returns TRUE if the editText
  7447. item is enabled or FALSE if it’s disabled. If a key-down or auto-key event is passed
  7448. when there’s no editText item, DialogSelect returns FALSE.
  7449.  
  7450. Note:  For a keyboard event, DialogSelect doesn’t check to see whether the
  7451.        Command key is held down; to handle keyboard equivalents of commands,
  7452.        you have to check for them before calling DialogSelect. Similarly, to
  7453.        treat a typed character in a special way (such as ignore it, or make
  7454.        it have the same effect as another character or as clicking a button),
  7455.        you need to check for a key-down event with that character before
  7456.        calling DialogSelect.
  7457.  
  7458. If the event is a mouse-down event in a control, DialogSelect calls the Control
  7459. Manager function TrackControl. If the mouse button is released inside the control and
  7460. the control is enabled, DialogSelect returns TRUE; otherwise, it returns FALSE.
  7461.  
  7462. If the event is a mouse-down event in any other enabled item, DialogSelect returns
  7463. TRUE. If it’s a mouse-down event in any other disabled item or in no item, or if it’s
  7464. any other event, DialogSelect returns FALSE.
  7465.  
  7466. Note:  If the event isn’t one that DialogSelect specifically checks for (if
  7467.        it’s a null event, for example), and there’s an editText item in the
  7468.        dialog, DialogSelect calls the TextEdit procedure TEIdle to make the
  7469.        caret blink.
  7470.  
  7471. æKY DialogTemplate,DialogTPtr,DialogTHndl
  7472. æFp Dialogs.p
  7473. æT TYPE
  7474. æC DialogTPtr = ^DialogTemplate;
  7475. DialogTHndl = ^DialogTPtr;
  7476. DialogTemplate = RECORD
  7477.    boundsRect: Rect;
  7478.    procID: INTEGER;
  7479.    visible: BOOLEAN;
  7480.    filler1: BOOLEAN;
  7481.    goAwayFlag: BOOLEAN;
  7482.    filler2: BOOLEAN;
  7483.    refCon: LONGINT;
  7484.    itemsID: INTEGER;
  7485.    title: Str255;
  7486.    END;
  7487.  
  7488. »Dialog Templates in Memory
  7489.  
  7490. The data structure of a dialog template is as follows:
  7491.  
  7492. TYPE DialogTemplate = RECORD
  7493.                         boundsRect:  Rect;     {becomes window's portRect}
  7494.                         procID:      INTEGER;  {window definiton ID}
  7495.                         visible:     BOOLEAN;  {TRUE if visible}
  7496.                         filler1:     BOOLEAN;  {not used}
  7497.                         goAwayFlag:  BOOLEAN;  {TRUE if has go-away region}
  7498.                         filler2:     BOOLEAN;  {not used}
  7499.                         refCon:      LONGINT;  {window's reference value}
  7500.                         itemsID:     INTEGER;  {resource ID of item list}
  7501.                         title:       Str255    {window's title}
  7502.                       END;
  7503.  
  7504. The filler1 and filler2 fields are there because for historical reasons the goAwayFlag
  7505. and refCon fields have to begin on a word boundary. The itemsID field contains the
  7506. resource ID of the dialog’s item list. The other fields are the same as the parameters
  7507. of the same name in the NewDialog function; they provide information about the dialog
  7508. window.
  7509.  
  7510. You access the dialog template by converting the handle returned by the Resource
  7511. Manager to a template handle:
  7512.  
  7513. TYPE  DialogTHndl  = ^DialogTPtr;
  7514.       DialogTPtr   = ^DialogTemplate;
  7515.  
  7516. æKY DisposDialog
  7517. æFp Dialogs.p
  7518. æT PROCEDURE
  7519. æTN $A983
  7520. æD PROCEDURE DisposDialog(theDialog: DialogPtr);
  7521. æDT DisposDialog(theDialog);
  7522. æRI DisposDialog procedure I-415
  7523. æC 
  7524. DisposDialog calls CloseDialog (above) and then releases the memory occupied by the
  7525. dialog’s item list and dialog record. Call DisposDialog when you’re done with a
  7526. dialog if you let the dialog record be allocated in the heap when you created the
  7527. dialog (by passing NIL as the dStorage parameter to NewDialog or GetNewDialog).
  7528.  
  7529. æKY DlgCopy
  7530. æFp Dialogs.p
  7531. æT PROCEDURE
  7532. æD PROCEDURE DlgCopy(theDialog: DialogPtr);
  7533. æDT DlgCopy(theDialog);
  7534. æMM 
  7535. æRT 215
  7536. æRI DlgCopy procedure I-418, P-110
  7537. æC 
  7538. [Not in ROM]
  7539. DlgCopy is the same as DlgCut (above) except that it calls TECopy, for handling the
  7540. Copy command.
  7541.  
  7542. æKY DlgCut
  7543. æFp Dialogs.p
  7544. æT PROCEDURE
  7545. æD PROCEDURE DlgCut(theDialog: DialogPtr);
  7546. æDT DlgCut(theDialog);
  7547. æRT 215
  7548. æRI DlgCut procedure I-418, P-110
  7549. æC 
  7550. [Not in ROM]
  7551. DlgCut checks whether theDialog has any editText items and, if so, applies the TextEdit
  7552. procedure TECut to the currently selected editText item. (If the dialog record’s
  7553. editField is 0 or greater, DlgCut passes the contents of the textH field to TECut.)
  7554. You can call DlgCut to handle the editing command Cut when a modeless dialog window
  7555. is active.
  7556.  
  7557. Assembly-language note:  Assembly-language programmers can just read the
  7558.                          dialog record’s fields and call TextEdit directly.
  7559.  
  7560. æKY DlgDelete
  7561. æFp Dialogs.p
  7562. æT PROCEDURE
  7563. æD PROCEDURE DlgDelete(theDialog: DialogPtr);
  7564. æDT DlgDelete(theDialog);
  7565. æMM 
  7566. æRT 215
  7567. æRI DlgDelete procedure I-418, P-110
  7568. æC  
  7569. [Not in ROM]
  7570.  
  7571. DlgDelete is the same as DlgCut (above) except that it calls TEDelete, for handling
  7572. the Clear command.
  7573.  
  7574. æKY DlgPaste
  7575. æFp Dialogs.p
  7576. æT PROCEDURE
  7577. æD PROCEDURE DlgPaste(theDialog: DialogPtr);
  7578. æDT DlgPaste(theDialog);
  7579. æMM 
  7580. æRT 215
  7581. æRI DlgPaste procedure I-418, P-110
  7582. æC  
  7583. [Not in ROM]
  7584.  
  7585. DlgPaste is the same as DlgCut (above) except that it calls TEPaste, for handling the
  7586. Paste command.
  7587.  
  7588. æKY DrawDialog
  7589. æFp Dialogs.p
  7590. æT PROCEDURE
  7591. æTN $A981
  7592. æD PROCEDURE DrawDialog(theDialog: DialogPtr);
  7593. æDT DrawDialog(theDialog);
  7594. æMM   
  7595. æRI DrawDialog procedure I-418
  7596. æC 
  7597. DrawDialog draws the contents of the given dialog box. Since DialogSelect and ModalDialog
  7598. handle dialog window updating, this procedure is useful only in unusual situations.
  7599. You would call it, for example, to display a dialog box that doesn’t require any
  7600. response but merely tells the user what’s going on during a time-consuming process.
  7601.  
  7602. æKY ErrorSound
  7603. æFp Dialogs.p
  7604. æT PROCEDURE
  7605. æTN $A98C
  7606. æD PROCEDURE ErrorSound(soundProc: ProcPtr);
  7607. æDT ErrorSound(soundProc);
  7608. æRI ErrorSound procedure I-411
  7609. æC  
  7610. ErrorSound sets the sound procedure for alerts to the procedure pointed to by soundProc;
  7611. if you don’t call ErrorSound, the Dialog Manager uses the standard sound procedure.
  7612. (For details, see the “Alerts” section.) If you pass NIL for soundProc, there will be
  7613. no sound (or menu bar blinking) at all.
  7614.  
  7615. Assembly-language note:  The address of the sound procedure being used is
  7616.                          stored in the global variable DABeeper.
  7617.  
  7618. æKY FindDItem
  7619. æFp Dialogs.p
  7620. æT FUNCTION
  7621. æTN $A984
  7622. æD FUNCTION FindDItem(theDialog: DialogPtr;thePt: Point): INTEGER;
  7623. æDT myVariable := FindDItem(theDialog,thePt);
  7624. æMM 
  7625. æRT 112
  7626. æRI FindDItem function  IV-60, N112
  7627. æC 
  7628. FindDItem returns the item number of the item containing the point specified, in
  7629. local coordinates, by thePt. If the point doesn’t lie within the item’s rectangle,
  7630. FindDItem returns –1. If there are overlapping items, it returns the item number of
  7631. the first item in the list containing the point. FindDItem is useful for changing the
  7632. cursor when it’s over a particular item.
  7633.  
  7634. Note:  FindDItem will return the item number of disabled items as well.
  7635.  
  7636. æKY FreeAlert
  7637. æFp Dialogs.p
  7638. æT PROCEDURE
  7639. æTN $A98A
  7640. æD PROCEDURE FreeAlert(alertID: INTEGER);
  7641. æDT FreeAlert(alertID);
  7642. æMM   
  7643. æRI FreeAlert procedure I-420, V-285
  7644. æC 
  7645. Given the resource ID of an alert template previously specified in a call to CouldAlert,
  7646. FreeAlert undoes the effect of CouldAlert (by making the resources purgeable). It
  7647. should be called when there’s no longer a need to keep the resources in memory.
  7648.  
  7649. Given the resource ID of an alert template previously specified in a call to CouldAlert,
  7650. the FreeAlert routine undoes the effect of CouldAlert, by restoring the original
  7651. purge state of the color table and color item list resources.
  7652.  
  7653. æKY FreeDialog
  7654. æFp Dialogs.p
  7655. æT PROCEDURE
  7656. æTN $A97A
  7657. æD PROCEDURE FreeDialog(dialogID: INTEGER);
  7658. æDT FreeDialog(dialogID);
  7659. æMM   
  7660. æRI FreeDialog procedure I-415, V-284
  7661. æC 
  7662. Given the resource ID of a dialog template previously specified in a call to CouldDialog,
  7663. FreeDialog undoes the effect of CouldDialog (by making the resources purgeable). It
  7664. should be called when there’s no longer a need to keep the resources in memory.
  7665.  
  7666. Given the resource ID of a dialog template previously specified in a call to CouldDialog,
  7667. the FreeDialog routine undoes the effect of CouldDialog, by restoring the original
  7668. purge state of the color table and color item list resources.
  7669.  
  7670. æKY GetAlrtStage
  7671. æFp Dialogs.p
  7672. æT FUNCTION
  7673. æD FUNCTION GetAlrtStage: INTEGER;
  7674. æDT myVariable := GetAlrtStage;
  7675. æRI GetAlrtStage function I-422
  7676. æC  
  7677. GetAlrtStage returns the stage of the last occurrence of an alert, as a number from 0
  7678. to 3.
  7679.  
  7680. Assembly-language note:  Assembly-language programmers can get this number
  7681.                          by accessing the global variable ACount. In addition,
  7682.                          the global variable ANumber contains the resource ID
  7683.                          of the alert template of the last alert that occurred.
  7684.  
  7685. æKY GetDItem
  7686. æFp Dialogs.p
  7687. æT PROCEDURE
  7688. æTN $A98D
  7689. æD PROCEDURE GetDItem(theDialog: DialogPtr;itemNo: INTEGER;VAR itemType: INTEGER;
  7690.     VAR item: Handle;VAR box: Rect);
  7691. æDT GetDItem(theDialog,itemNo,itemType,item,box);
  7692. æMM   
  7693. æRI GetDItem procedure I-421
  7694. æC  
  7695. GetDItem returns in its VAR parameters the following information about the item
  7696. numbered itemNo in the given dialog’s item list:  In the itemType parameter, the item
  7697. type; in the item parameter, a handle to the item (or, for item type userItem, the
  7698. procedure pointer); and in the box parameter, the display rectangle for the item.
  7699.  
  7700. Suppose, for example, that you want to change the title of a control in a dialog box.
  7701. You can get the item handle with GetDItem, coerce it to type ControlHandle, and call
  7702. the Control Manager procedure SetCTitle to change the title. Similarly, to move the
  7703. control or change its size, you would call MoveControl or SizeControl.
  7704.  
  7705. Note:  To access the text of a statText or editText item, you can pass the
  7706.        handle returned by GetDItem to GetIText or SetIText (see below).
  7707.  
  7708. æKY GetIText
  7709. æFp Dialogs.p
  7710. æT PROCEDURE
  7711. æTN $A990
  7712. æD PROCEDURE GetIText(item: Handle;VAR text: Str255);
  7713. æDT GetIText(item,text);
  7714. æRT 18
  7715. æRI GetIText procedure I-422, N18-2
  7716. æC  
  7717. Given a handle to a statText or editText item in a dialog box, as returned by GetDItem,
  7718. GetIText returns the text of the item in the text parameter. (If the user typed more
  7719. than 255 characters in an editText item, GetIText returns only the first 255.)
  7720.  
  7721. æKY GetNewDialog
  7722. æFp Dialogs.p
  7723. æT FUNCTION
  7724. æTN $A97C
  7725. æD FUNCTION GetNewDialog(dialogID: INTEGER;dStorage: Ptr;behind: WindowPtr): DialogPtr;
  7726. æDT myVariable := GetNewDialog(dialogID,dStorage,behind);
  7727. æMM 
  7728. æRT 4,34
  7729. æRI GetNewDialog function I-413, V-284, N4-1,  P-107, 172
  7730. æC 
  7731. Like NewDialog (above), GetNewDialog creates a dialog as specified by its parameters
  7732. and returns a pointer to the new dialog. Instead of having the parameters boundsRect,
  7733. title, visible, procID, goAwayFlag, and refCon, GetNewDialog has a single dialogID
  7734. parameter, where dialogID is the resource ID of a dialog template that supplies the
  7735. same information as those parameters. The dialog template also contains the resource
  7736. ID of the dialog’s item list. After calling the Resource Manager to read the item
  7737. list into memory (if it’s not already in memory), GetNewDialog makes a copy of the
  7738. item list and uses that copy; thus you may have multiple independent dialogs whose
  7739. items have the same types, locations, and initial contents. The dStorage and behind
  7740. parameters of GetNewDialog have the same meaning as in NewDialog.
  7741.  
  7742. Warning:  If either the dialog template resource or the item list
  7743.           resource can’t be read, the function result is undefined.
  7744.  
  7745. Note:  GetNewDialog doesn’t release the memory occupied by the resources.
  7746.  
  7747. The GetNewDialog routine will attempt to load a 'dctb' resource and returns a pointer
  7748. to a color grafPort if the resource exists. If no 'dctb' resource is present, GetNewDialog
  7749. returns a pointer to an old grafPort.
  7750.  
  7751. The dialog color table is copied before it is passed to SetWinSize unless its ctSize
  7752. field is equal to –1, indicating that the default window colors are to be used instead.
  7753. The copy is made so that the color table resource can be purged without affecting the
  7754. dialog.
  7755.  
  7756. The color dialog item list resource is duplicated as well, so it can be purgeable.
  7757.  
  7758. æKY HideDItem
  7759. æFp Dialogs.p
  7760. æT PROCEDURE
  7761. æTN $A827
  7762. æD PROCEDURE HideDItem(theDialog: DialogPtr;itemNo: INTEGER);
  7763. æDT HideDItem(theDialog,itemNo);
  7764. æMM   
  7765. æRI HideDItem procedure  IV-59
  7766. æC 
  7767. HideDItem hides the item numbered itemNo in the given dialog’s item list by giving
  7768. the item a display rectangle that’s off the screen. (Specifically, if the left coordinate
  7769. of the item’s display rectangle is less than 8192, ShowDItem adds 16384 to both the
  7770. left and right coordinates the rectangle.) If the item is already hidden (that is, if
  7771. the left coordinate is greater than 8192), HideDItem does nothing.
  7772.  
  7773. HideDItem calls the EraseRect procedure on the item’s enclosing rectangle and adds
  7774. the rectangle that contained the item (not necessarily the item’s display rectangle)
  7775. to the update region. If the specified item is an active editText item, the item is
  7776. first deactivated (by calling TEDeactivate).
  7777.  
  7778. Note:  If you have items that are close to each other, be aware that the
  7779.        Dialog Manager draws outside of the enclosing rectangle by 3 pixels
  7780.        for editText items and by 4 pixels for a default button.
  7781.  
  7782. An item that’s been hidden by HideDItem can be redisplayed by the ShowDItem procedure.
  7783.  
  7784. Note:  To create a hidden item in a dialog item list, simply add 16384 to
  7785.        the left and right coordinates of the display rectangle.
  7786.  
  7787. æKY InitDialogs
  7788. æFp Dialogs.p
  7789. æT PROCEDURE
  7790. æTN $A97B
  7791. æD PROCEDURE InitDialogs(resumeProc: ProcPtr);
  7792. æDT InitDialogs(resumeProc);
  7793. æRI InitDialogs procedure I-411, P-107, 112, 174
  7794. æC  
  7795. Call InitDialogs once before all other Dialog Manager routines, to initialize the
  7796. Dialog Manager. InitDialogs does the following initialization:
  7797.  
  7798.   •  It saves the pointer passed in resumeProc, if any, for access by the
  7799.      System Error Handler in case a fatal system error occurs. ResumeProc
  7800.      can be a pointer to a resume procedure, as described in the System
  7801.      Error Handler chapter, or NIL if no such procedure is desired.
  7802.  
  7803. Assembly-language note:  InitDialogs stores the address of the resume
  7804.                          procedure in a global variable named ResumeProc.
  7805.  
  7806.   •  It installs the standard sound procedure.
  7807.   •  It passes empty strings to ParamText.
  7808.  
  7809. æKY IsDialogEvent
  7810. æFp Dialogs.p
  7811. æT Function
  7812. æTN $A97F
  7813. æD FUNCTION IsDialogEvent(theEvent: EventRecord): BOOLEAN;
  7814. æDT myVariable := IsDialogEvent(theEvent);
  7815. æRI IsDialogEvent function I-416, N5-1, P-108, 175
  7816. æC  
  7817. If your application includes any modeless dialogs, call IsDialogEvent after calling
  7818. the Toolbox Event Manager function GetNextEvent.
  7819.  
  7820. Warning:  If your modeless dialog contains any editText items, you must call
  7821.           IsDialogEvent (and then DialogSelect) even if GetNextEvent returns
  7822.           FALSE; otherwise your dialog won’t receive null events and the
  7823.           caret won’t blink.
  7824.  
  7825. Pass the current event in theEvent. IsDialogEvent determines whether theEvent needs
  7826. to be handled as part of a dialog. If theEvent is an activate or update event for a
  7827. dialog window, a mouse-down event in the content region of an active dialog window,
  7828. or any other type of event when a dialog window is active, IsDialogEvent returns
  7829. TRUE; otherwise, it returns FALSE.
  7830.  
  7831. When FALSE is returned, just handle the event yourself like any other event that’s
  7832. not dialog-related. When TRUE is returned, you’ll generally end up passing the event
  7833. to DialogSelect for it to handle (as described below), but first you should do some
  7834. additional checking:
  7835.  
  7836.   •  DialogSelect doesn’t handle keyboard equivalents of commands. Check
  7837.      whether the event is a key-down event with the Command key held down
  7838.      and, if so, carry out the command if it’s one that applies when a
  7839.      dialog window is active. (If the command doesn’t so apply, do nothing.)
  7840.   •  In special cases, you may want to bypass DialogSelect or do some
  7841.      preprocessing before calling it. If so, check for those events and
  7842.      respond accordingly. You would need to do this, for example, if the
  7843.      dialog is to respond to disk-inserted events.
  7844.  
  7845. For cases other than these, pass the event to DialogSelect for it to handle.
  7846.  
  7847. æKY ModalDialog
  7848. æFp Dialogs.p
  7849. æT PROCEDURE
  7850. æTN $A991
  7851. æD PROCEDURE ModalDialog(filterProc: ProcPtr;VAR itemHit: INTEGER);
  7852. æDT ModalDialog(filterProc,itemHit);
  7853. æMM 
  7854. æRT 34, 203
  7855. æRI ModalDialog procedure  I-415, N34-2, 3,   P-108, 176
  7856. æC  
  7857. Call ModalDialog after creating a modal dialog and bringing up its window in the
  7858. frontmost plane. ModalDialog repeatedly gets and handles events in the dialog’s
  7859. window; after handling an event involving an enabled dialog item, it returns with the
  7860. item number in itemHit. Normally you’ll then do whatever is appropriate as a response
  7861. to an event in that item.
  7862.  
  7863. ModalDialog gets each event by calling the Toolbox Event Manager function GetNextEvent.
  7864. If the event is a mouse-down event outside the content region of the dialog window,
  7865. ModalDialog emits sound number 1 (which should be a single beep) and gets the next
  7866. event; otherwise, it filters and handles the event as described below.
  7867.  
  7868. Note:  Once before getting each event, ModalDialog calls SystemTask, a
  7869.        Desk Manager procedure that must be called regularly so that desk
  7870.        accessories will work properly.
  7871.  
  7872. The filterProc parameter determines how events are filtered. If it’s NIL, the standard
  7873. filterProc function is executed; this causes ModalDialog to return 1 in itemHit if
  7874. the Return key or Enter key is pressed. If filterProc isn’t NIL, ModalDialog filters
  7875. events by executing the function it points to. Your filterProc function should have
  7876. three parameters and return a Boolean value. For example, this is how it would be
  7877. declared if it were named MyFilter:
  7878.  
  7879. FUNCTION MyFilter (theDialog:  DialogPtr; VAR theEvent:  EventRecord;
  7880.                    VAR itemHit:  INTEGER) :  BOOLEAN;
  7881.  
  7882. A function result of FALSE tells ModalDialog to go ahead and handle the event, which
  7883. either can be sent through unchanged or can be changed to simulate a different event.
  7884. A function result of TRUE tells ModalDialog to return immediately rather than handle
  7885. the event; in this case, the filterProc function sets itemHit to the item number that
  7886. ModalDialog should return.
  7887.  
  7888. Note:  If you want it to be consistent with the standard filterProc function,
  7889.        your function should at least check whether the Return key or Enter
  7890.        key was pressed and, if so, return 1 in itemHit and a function result
  7891.        of TRUE.
  7892.  
  7893. You can use the filterProc function, for example, to treat a typed character in a
  7894. special way (such as ignore it, or make it have the same effect as another character
  7895. or as clicking a button); in this case, the function would test for a key-down event
  7896. with that character. As another example, suppose the dialog box contains a userItem
  7897. whose procedure draws a clock with the current time displayed. The filterProc function
  7898. can call that procedure and return FALSE without altering the current event.
  7899.  
  7900. Note:  ModalDialog calls GetNextEvent with a mask that excludes disk-inserted
  7901.        events. To receive disk-inserted events, your filterProc function can
  7902.        call GetNextEvent (or EventAvail) with a mask that accepts only that
  7903.        type of event.
  7904.  
  7905. ModalDialog handles the events for which the filterProc function returns FALSE as
  7906. follows:
  7907.  
  7908.   •  In response to an activate or update event for the dialog window,
  7909.      ModalDialog activates or updates the window.
  7910.   •  If the mouse button is pressed in an editText item, ModalDialog
  7911.      responds to the mouse activity as appropriate (displaying an insertion
  7912.      point or selecting text). If a key-down event occurs and there’s an
  7913.      editText item, text entry and editing are handled in the standard way
  7914.      for such items (except that if the Command key is down, ModalDialog
  7915.      responds as though it’s not). In either case, ModalDialog returns if
  7916.      the editText item is enabled or does nothing if it’s disabled. If a
  7917.      key-down event occurs when there’s no editText item, ModalDialog does
  7918.      nothing.
  7919.   •  If the mouse button is pressed in a control, ModalDialog calls the
  7920.      Control Manager function TrackControl. If the mouse button is released
  7921.      inside the control and the control is enabled, ModalDialog returns;
  7922.      otherwise, it does nothing.
  7923.   •  If the mouse button is pressed in any other enabled item in the
  7924.      dialog box, ModalDialog returns. If the mouse button is pressed in
  7925.      any other disabled item or in no item, or if any other event occurs,
  7926.      ModalDialog does nothing.
  7927.  
  7928. æKY NewCDialog
  7929. æFp Dialogs.p
  7930. æT FUNCTION
  7931. æTN $AA4B
  7932. æD FUNCTION NewCDialog(dStorage: Ptr;boundsRect: Rect;title: Str255;visible: BOOLEAN;
  7933.     procID: INTEGER;behind: WindowPtr;goAwayFlag: BOOLEAN;refCon: LONGINT;
  7934.     items: Handle): DialogPtr;
  7935. æDT myVariable := NewCDialog(dStorage,boundsRect,title,visible,procID,behind,
  7936.     goAwayFlag,refCon,items);
  7937. æMM   
  7938. æRI NewCDialog function  V-283
  7939. æC 
  7940. A new Dialog Manager routine has been added to support color dialogs: NewCDialog. 
  7941. Its parameters are identical to NewDialog, except that a cGrafPort is allocated
  7942. through a NewCWindow call instead of a call to NewWindow.
  7943.  
  7944. NewCDialog creates a dialog box as specified by its parameters and returns a cDialogPtr
  7945. to the new dialog. The first eight parameters (dStorage through refCon) are passed to
  7946. the Window Manager function NewCWindow, which creates the dialog window. The items
  7947. parameter is a handle to the dialog’s item list. You can get the items handle by
  7948. calling the Resource Manager to read the item list from the resource file into memory.
  7949.  
  7950. After calling NewCDialog, you can use SetWinColor to add a color table to the dialog.
  7951. This creates an auxiliary window record (auxWinRec) for the dialog window. You can
  7952. access this record with the GetAuxWin routine. The dialogCItem handle within the
  7953. auxWinRec points to the dialog item color table.
  7954.  
  7955. If the dialog’s content color isn’t white, it’s a good idea to call NewCDialog with
  7956. the visible flag set to FALSE. After the color table and color item list are installed,
  7957. use ShowWindow to display the dialog if the dialog is the frontmost window. If the
  7958. dialog is not in front, use ShowHide to display the dialog.
  7959.  
  7960. æKY NewDialog
  7961. æFp Dialogs.p
  7962. æT FUNCTION
  7963. æTN $A97D
  7964. æD FUNCTION NewDialog(wStorage: Ptr;boundsRect: Rect;title: Str255;visible: BOOLEAN;
  7965.     procID: INTEGER;behind: WindowPtr;goAwayFlag: BOOLEAN;refCon: LONGINT;
  7966.     itmLstHndl: Handle): DialogPtr;
  7967. æDT myVariable := NewDialog(wStorage,boundsRect,title,visible,procID,behind,
  7968.     goAwayFlag,refCon,itmLstHndl);
  7969. æMM   
  7970. æRI NewDialog function  I-412, P-107, 177
  7971. æC 
  7972. NewDialog creates a dialog as specified by its parameters and returns a pointer to
  7973. the new dialog. The first eight parameters (dStorage through refCon) are passed to
  7974. the Window Manager function NewWindow, which creates the dialog window; the meanings
  7975. of these parameters are summarized below. The items parameter is a handle to the
  7976. dialog’s item list. You can get the items handle by calling the Resource Manager to
  7977. read the item list from the resource file into memory.
  7978.  
  7979. Note:  Advanced programmers can create their own item lists in memory rather
  7980.        than have them read from a resource file. The exact format is given
  7981.        later under “Formats of Resources for Dialogs and Alerts”.
  7982.  
  7983. DStorage is analogous to the wStorage parameter of NewWindow; it’s a pointer to the
  7984. storage to use for the dialog record. If you pass NIL for dStorage, the dialog record
  7985. will be allocated in the heap (which, in the case of modeless dialogs, may cause the
  7986. heap to become fragmented).
  7987.  
  7988. BoundsRect, a rectangle given in global coordinates, determines the dialog window’s
  7989. size and location. It becomes the portRect of the window’s grafPort. Remember that
  7990. the top coordinate of this rectangle should be at least 25 points below the top of
  7991. the screen for a modal dialog, to allow for the menu bar and the border around the
  7992. portRect, and at least 40 points below the top of the screen for a modeless dialog,
  7993. to allow for the menu bar and the window’s title bar.
  7994.  
  7995. Title is the title of a modeless dialog box; pass the empty string for modal dialogs.
  7996.  
  7997. If the visible parameter is TRUE, the dialog window is drawn on the screen. If it’s
  7998. FALSE, the window is initially invisible and may later be shown with a call to the
  7999. Window Manager procedure ShowWindow.
  8000.  
  8001. Note:  NewDialog generates an update event for the entire window contents,
  8002.        so the items aren’t drawn immediately, with the exception of controls.
  8003.        The Dialog Manager calls the Control Manager to draw controls, and the
  8004.        Control Manager draws them immediately rather than via the standard
  8005.        update mechanism. Because of this, the Dialog Manager calls the Window
  8006.        Manager procedure ValidRect for the enclosing rectangle of each control,
  8007.        so the controls won’t be drawn twice. If you find that the other items
  8008.        aren’t being drawn soon enough after the controls, try making the
  8009.        window invisible initially and then calling ShowWindow to show it.
  8010.  
  8011. ProcID is the window definition ID, which leads to the window definition function for
  8012. this type of window. The window definition IDs for the standard types of dialog
  8013. window are dBoxProc for the modal type and documentProc for the modeless type.
  8014.  
  8015. The behind parameter specifies the window behind which the dialog window is to be
  8016. placed on the desktop. Pass POINTER(–1) to bring up the dialog window in front of all
  8017. other windows.
  8018.  
  8019. GoAwayFlag applies to modeless dialog boxes; if it’s TRUE, the dialog window has a
  8020. close box in its title bar when the window is active.
  8021.  
  8022. RefCon is the dialog window’s reference value, which the application may store into
  8023. and access for any purpose.
  8024.  
  8025. NewDialog sets the font of the dialog window’s grafPort to the system font or, if you
  8026. previously called SetDAFont, to the specified font. It also sets the window class in
  8027. the window record to dialogKind.
  8028.  
  8029. æKY NoteAlert
  8030. æFp Dialogs.p
  8031. æT FUNCTION
  8032. æTN $A987
  8033. æD FUNCTION NoteAlert(alertID: INTEGER;filterProc: ProcPtr): INTEGER;
  8034. æDT myVariable := NoteAlert(alertID,filterProc);
  8035. æMM   
  8036. æRI NoteAlert function I-420
  8037. æC  
  8038. NoteAlert is like StopAlert except that it draws the Note icon, which has the following
  8039. resource ID:
  8040.  
  8041. CONST noteIcon = 1;
  8042.  
  8043. The calls CautionAlert, StopAlert, and NoteAlert look for a resource of type
  8044. 'actb' with the same ID as the alert.
  8045.  
  8046. æKY ok,cancel
  8047. æFp Dialogs.p
  8048. æC 
  8049.   { Item numbers of OK and Cancel buttons }
  8050.  
  8051.   ok           = 1;
  8052.   cancel       = 2;
  8053.  
  8054. æKY ParamText
  8055. æFp Dialogs.p
  8056. æT PROCEDURE
  8057. æTN $A98B
  8058. æD PROCEDURE ParamText(param0: Str255;param1: Str255;param2: Str255;param3: Str255);
  8059. æDT ParamText(param0,param1,param2,param3);
  8060. æMM   
  8061. æRI ParamText procedure I-421
  8062. æC  
  8063. ParamText provides a means of substituting text in statText items:  param0 through
  8064. param3 will replace the special strings '^0' through '^3' in all statText items in
  8065. all subsequent dialog or alert boxes. Pass empty strings for parameters not used.
  8066.  
  8067. Assembly-language note:  Assembly-language programmers may pass NIL for
  8068.                          parameters not used or for strings that are not
  8069.                          to be changed.
  8070.  
  8071. For example, if the text is defined as 'Cannot open document ^0' and docName is a
  8072. string variable containing a document name that the user typed, you can call ParamText(docName,'
  8073. ',' ',' ')
  8074.  
  8075. Note:  All strings that may need to be translated to other languages should
  8076.        be stored in resource files.
  8077.  
  8078. Assembly-language note:  The Dialog Manager stores handles to the four
  8079.                          ParamText parameters in a global array named DAStrings.
  8080.  
  8081. æKY ResetAlrtStage
  8082. æFp Dialogs.p
  8083. æT PROCEDURE
  8084. æD PROCEDURE ResetAlrtStage;
  8085. æDT ResetAlrtStage;
  8086. æRI ResetAlrtStage procedure I-423
  8087. æC 
  8088. ResetAlrtStage resets the stage of the last occurrence of an alert so that the next
  8089. occurrence of that same alert will be treated as its first stage. This is useful, for
  8090. example, when you’ve used ParamText to change the text of an alert such that from the
  8091. user’s point of view it’s a different alert.
  8092.  
  8093. Assembly-language note:  Assembly-language programmers can set the global
  8094.                          variable ACount to –1 for the same effect.
  8095.  
  8096. æKY SelIText
  8097. æFp Dialogs.p
  8098. æT PROCEDURE
  8099. æTN $A97E
  8100. æD PROCEDURE SelIText(theDialog: DialogPtr;itemNo: INTEGER;strtSel: INTEGER;
  8101.     endSel: INTEGER);
  8102. æDT SelIText(theDialog,itemNo,strtSel,endSel);
  8103. æMM   
  8104. æRI SelIText procedure I-422, P-110
  8105. æC 
  8106. Given a pointer to a dialog and the item number of an editText item in the dialog
  8107. box, SelIText does the following:
  8108.  
  8109.   •  If the item contains text, SelIText sets the selection range to extend
  8110.      from character position strtSel up to but not including character
  8111.      position endSel. The selection range is inverted unless strtSel equals
  8112.      endSel, in which case a blinking vertical bar is displayed to indicate
  8113.      an insertion point at that position.
  8114.   •  If the item doesn’t contain text, SelIText simply displays the insertion
  8115.      point.
  8116.  
  8117. For example, if the user makes an unacceptable entry in the editText item, the application
  8118. can put up an alert box reporting the problem and then select the entire text of the
  8119. item so it can be replaced by a new entry. (Without this procedure, the user would
  8120. have to select the item before making the new entry.)
  8121.  
  8122. Note:  You can select the entire texxt by specifying 0 for strtSel and 32767
  8123.        for endSel. For details about selection range and character position,
  8124.        see the TextEdit chapter.
  8125.  
  8126. æKY SetDAFont
  8127. æFp Dialogs.p
  8128. æT PROCEDURE
  8129. æD PROCEDURE SetDAFont(fontNum: INTEGER);
  8130. æDT SetDAFont(fontNum);
  8131. æRI SetDAFont procedure I-412
  8132. æC 
  8133. For subsequently created dialogs and alerts, SetDAFont causes the font of the dialog
  8134. or alert window’s grafPort to be set to the font having the specified font number. If
  8135. you don’t call this procedure, the system font is used. SetDAFont affects statText
  8136. and editText items but not titles of controls, which are always in the system font.
  8137.  
  8138. Assembly-language note:  Assembly-language programmers can simply set
  8139.                          the global variable DlgFont to the desired font number.
  8140.  
  8141. æKY SetDItem
  8142. æFp Dialogs.p
  8143. æT PROCEDURE
  8144. æTN $A98E
  8145. æD PROCEDURE SetDItem(theDialog: DialogPtr;itemNo: INTEGER;itemType: INTEGER;
  8146.     item: Handle;box: Rect);
  8147. æDT SetDItem(theDialog,itemNo,itemType,item,box);
  8148. æMM 
  8149. æRT 34
  8150. æRI SetDItem procedure I-421, N34-1
  8151. æC  
  8152. SetDItem sets the item numbered itemNo in the given dialog’s item list, as specified
  8153. by the parameters (without drawing the item). The itemType parameter is the item
  8154. type; the item parameter is a handle to the item (or, for item type userItem, the
  8155. procedure pointer); and the box parameter is the display rectangle for the item.
  8156.  
  8157. Consider, for example, how to install an item of type userItem in a dialog:  In the
  8158. item list in the resource file, define an item in which the type is set to userItem
  8159. and the display rectangle to (0,0)(0,0). Specify that the dialog window be invisible
  8160. (in either the dialog template or the NewDialog call). After creating the dialog,
  8161. coerce the item’s procedure pointer to type Handle; then call SetDItem, passing that
  8162. handle and the display rectangle for the item. Finally, call the Window Manager
  8163. procedure ShowWindow to display the dialog window.
  8164.  
  8165. Note:  Do not use SetDItem to change the text of a statText or editText item
  8166.        or to change or move a control. See the description of GetDItem above
  8167.        for more information.
  8168.  
  8169. æKY SetIText
  8170. æFp Dialogs.p
  8171. æT PROCEDURE
  8172. æTN $A98F
  8173. æD PROCEDURE SetIText(item: Handle;text: Str255);
  8174. æDT SetIText(item,text);
  8175. æMM   
  8176. æRI SetIText procedure I-422
  8177. æC 
  8178. Given a handle to a statText or editText item in a dialog box, as returned by GetDItem,
  8179. SetIText sets the text of the item to the specified text and draws the item. For
  8180. example, suppose the exact content of a dialog’s text item cannot be determined until
  8181. the application is running, but the display rectangle is defined in the resource
  8182. file:  Call GetDItem to get a handle to the item, and call SetIText with the desired
  8183. text.
  8184.  
  8185. æKY ShowDItem
  8186. æFp Dialogs.p
  8187. æT PROCEDURE
  8188. æTN $A828
  8189. æD PROCEDURE ShowDItem(theDialog: DialogPtr;itemNo: INTEGER);
  8190. æDT ShowDItem(theDialog,itemNo);
  8191. æMM   
  8192. æRI ShowDItem procedure  IV-59
  8193. æC 
  8194. ShowDItem redisplays the item numbered itemNo, previously hidden by HideDItem, by
  8195. giving the item the display rectangle it had prior to the HideDItem call.
  8196. (Specifically, if the left coordinate of the item’s display rectangle is greater than
  8197. 8192, ShowDItem subtracts 16384 from both the left and right coordinates the rectangle.)
  8198. If the item is already visible (that is, if the left coordinate is less than 8192),
  8199. ShowDItem does nothing.
  8200.  
  8201. ShowDItem adds the rectangle that contained the item (not necessarily the
  8202. item’s display rectangle) to the update region so that it will be drawn. If the item
  8203. becomes the only editText item, ShowDItem activates it (by calling TEActivate).
  8204.  
  8205. æKY StageList
  8206. æFp Dialogs.p
  8207. æT PACKED RECORD
  8208. æC StageList = PACKED RECORD
  8209.    boldItm4: 0..1;     {default button item number - 1}
  8210.    boxDrwn4: BOOLEAN;  {true if alert box to be drawn}
  8211.    sound4: 0..3;       {sound number}
  8212.    boldItm3: 0..1;
  8213.    boxDrwn3: BOOLEAN;
  8214.    sound3: 0..3;
  8215.    boldItm2: 0..1;
  8216.    boxDrwn2: BOOLEAN;
  8217.    sound2: 0..3;
  8218.    boldItm1: 0..1;
  8219.    boxDrwn1: BOOLEAN;
  8220.    sound1: 0..3;
  8221.    END;
  8222.  
  8223. »Alert Templates in Memory
  8224.  
  8225. The data structure of an alert template is as follows:
  8226.  
  8227. TYPE AlertTemplate = RECORD
  8228.                        boundsRect:  Rect;      {becomes window's portRect}
  8229.                        itemsID:     INTEGER;   {resource ID of item list}
  8230.                        stages:      StageList  {alert stage information}
  8231.                      END;
  8232.  
  8233. BoundsRect is the rectangle that becomes the portRect of the window's grafPort. The
  8234. itemsID field contains the resource ID of the item list for the alert.
  8235.  
  8236. The information in the stages field determines exactly what should happen at each
  8237. stage of the alert. It's packed into a word that has the following structure:
  8238.  
  8239. TYPE StageList = PACKED RECORD
  8240.                    boldItm4:  0..1;     {default button item number minus 1}
  8241.                    boxDrwn4:  BOOLEAN;  {TRUE if alert box to be drawn}
  8242.                    sound4:    0..3      {sound number}
  8243.                    boldItm3:  0..1; 
  8244.                    boxDrwn3:  BOOLEAN; 
  8245.                    sound3:    0..3 
  8246.                    boldItm2:  0..1; 
  8247.                    boxDrwn2:  BOOLEAN; 
  8248.                    sound2:    0..3 
  8249.                    boldItm1:  0..1; 
  8250.                    boxDrwn1:  BOOLEAN; 
  8251.                    sound1:    0..3 
  8252.                  END;
  8253.  
  8254. Notice that the information is stored in reverse order—for the fourth stage first,
  8255. and for the first stage last.
  8256.  
  8257. The boldItm field indicates which button should be the default button (and therefore
  8258. boldly outlined in the alert box). If the first two items in the alert’s item list
  8259. are the OK button and the Cancel button, respectively, 0 will refer to the OK button
  8260. and 1 to the Cancel button. The reason for this is that the value of boldItm plus 1
  8261. is interpreted as an item number, and normally items 1 and 2 are the OK and Cancel
  8262. buttons, respectively. Whatever the item having the corresponding item number happens
  8263. to be, a bold rounded-corner rectangle will be drawn outside its display rectangle.
  8264.  
  8265. Note:  When deciding where to place items in an alert box, be sure to allow
  8266.        room for any bold outlines that may be drawn.
  8267.  
  8268. The boxDrwn field is TRUE if the alert box is to be drawn.
  8269.  
  8270. The sound field specifies which sound should be emitted at this stage of the alert,
  8271. with a number from 0 to 3 that’s passed to the current sound procedure. You can call
  8272. ErrorSound to specify your own sound procedure; if you don’t, the standard sound
  8273. procedure will be used (as described earlier in the “Alerts” section).
  8274.  
  8275. You access the alert template by converting the handle returned by the Resource
  8276. Manager to a template handle:
  8277.  
  8278. TYPE  AlertTHndl = ^AlertTPtr;
  8279.       AlertTPtr  = ^AlertTemplate;
  8280.  
  8281. Assembly-language note:  Rather than offsets into the fields of the StageList
  8282.                          data structure, there are masks for accessing the
  8283.                          information stored for an alert stage in a stages
  8284.                          word; they’re listed in the summary at the end of
  8285.                          this chapter.
  8286. æKY StopAlert
  8287. æFp Dialogs.p
  8288. æT FUNCTION
  8289. æTN $A986
  8290. æD FUNCTION StopAlert(alertID: INTEGER;filterProc: ProcPtr): INTEGER;
  8291. æDT myVariable := StopAlert(alertID,filterProc);
  8292. æMM   
  8293. æRI StopAlert function I-419, V-284, P-109, 182
  8294. æC  
  8295. StopAlert is the same as the Alert function (above) except that before drawing the
  8296. items of the alert in the alert box, it draws the Stop icon in the top left corner of
  8297. the box (within the rectangle (10,20)(42,52)). The Stop icon has the following resource
  8298. ID:
  8299.  
  8300. CONST stopIcon = 0;
  8301.  
  8302. If the application’s resource file doesn’t include an icon with that ID number, the
  8303. Dialog Manager uses the standard Stop icon in the system resource file (see Figure
  8304. 11).
  8305.  
  8306. The calls CautionAlert, StopAlert, and NoteAlert look for a resource of type
  8307. 'actb' with the same ID as the alert.
  8308.  
  8309. •••Refer to Figure 11.•••
  8310.  
  8311. Figure 11–Standard Alert Icons
  8312.  
  8313. æKY stopIcon,noteIcon,cautionIcon
  8314. æFp Dialogs.p
  8315. æC 
  8316.   { Resource IDs of alert icons }
  8317.  
  8318.   stopIcon     = 0;
  8319.   noteIcon     = 1;
  8320.   cautionIcon  = 2;
  8321.  
  8322. æKY UpdtDialog
  8323. æFp Dialogs.p
  8324. æT PROCEDURE
  8325. æTN $A978
  8326. æD PROCEDURE UpdtDialog(theDialog: DialogPtr;updateRgn: RgnHandle);
  8327. æDT UpdtDialog(theDialog,updateRgn);
  8328. æMM   
  8329. æRI UpdtDialog procedure  IV-60
  8330. æC  
  8331. UpdtDialog is a faster version of the DrawDialog procedure. Instead of drawing the
  8332. entire contents of the given dialog box, UpdtDialog draws only the items that are in
  8333. a specified update region. UpdtDialog is called in response to an update event, and
  8334. is usually bracketed by calls to the Window Manager procedures BeginUpdate and EndUpdate.
  8335. UpdateRgn should be set to the visRgn of theWindow’s port. (For more details, see the
  8336. BeginUpdate procedure in the Window Manager chapter.)
  8337.  
  8338. æKY DisAsmLookup.p
  8339. æKL Disassembler
  8340. endOfModule
  8341. InitLookup
  8342. Lookup
  8343. LookupTrapName
  8344. ModifyOperand
  8345. showMacsBugSymbol
  8346. validMacsBugSymbol
  8347.  
  8348. DisAsmStr80
  8349. LookupRegs
  8350. _A0_
  8351. _A1_
  8352. _A2_
  8353. _A3_
  8354. _A4_
  8355. _A5_
  8356. _A6_
  8357. _A7_
  8358. _ABS_
  8359. _PC_
  8360. _TRAP_
  8361.  
  8362. æKY DisAsmStr80
  8363. æFp DisAsmLookup.p
  8364. æT TYPE
  8365. æC DisAsmStr80 = String[80];
  8366.  
  8367. æKY Disassembler
  8368. æFp DisAsmLookup.p
  8369. æT PROCEDURE
  8370. æD PROCEDURE Disassembler(DstAdjust: LONGINT;VAR BytesUsed: INTEGER;FirstByte: UNIV Ptr;
  8371.     VAR Opcode: UNIV DisAsmStr80;VAR Operand: UNIV DisAsmStr80;VAR Comment: UNIV DisAsmStr80;
  8372.     LookUpProc: UNIV Ptr);
  8373. æDT Disassembler(DstAdjust,BytesUsed,FirstByte,Opcode,Operand,Comment,LookUpProc);
  8374. æC 
  8375. (*
  8376. Disassembler is a Pascal routine to be called to disassemble a sequence of
  8377. bytes.  All MC68xxx, MC68881, and MC68851 instructions are supported.  The
  8378. sequence of bytes to be disassembled are pointed to by FirstByte.  BytesUsed
  8379. bytes starting at FirstByte are consumed by the disassembly, and the Opcode,
  8380. Operand, and Comment strings returned as NULL TERMINATED Pascal strings (for
  8381. easier manipulation with C).  The caller is then free to format or use the
  8382. output strings any way appropriate to the application.
  8383.  
  8384. Depending on the opcode and effective address(s) (EA's) to be disassembled,
  8385. the Opcode, Operand, and Comment strings contain the following information:
  8386.  
  8387. Case                     Opcode    Operand    Comment
  8388. =======================================================================
  8389. Non PC-relative EA's     op.sz     EA's
  8390. PC-relative EA's         op.sz     EA's       ; address
  8391. Toolbox traps            DC.W      $AXXX      ; TB XXXX
  8392. OS traps                 DC.W      $AXXX      ; OS XXXX
  8393. Invalid bytes            DC.W      $XXXX      ; ????
  8394. Invalid byte #immediate  DC.W      $XXXX,...  ; op.sz #$??XX,EA
  8395. =======================================================================
  8396.  
  8397. For valid disassembly of processor instructions the appropriate MC68XXX
  8398. opcode mnemonic is generated for the Opcode string along with a size
  8399. attribute when required. The source and destination EA's are generated as the
  8400. Operand along with a possible comment.  Comments start with a ';'.  Traps use
  8401. a DC.W assembler directive as the Opcode with the trap word as the Operand
  8402. and a comment indicating whether the trap is a toolbox or OS trap and what
  8403. the trap number is.  As described later the caller can generate symbolic
  8404. substitutions into EA's and provide names for traps.
  8405.  
  8406. Invalid instructions cause the string 'DC.W' to be returned in the Opcode
  8407. string. Operand is '$XXXX' (the invalid word) with a comment of '; ????'.
  8408. BytesUsed is 2. This is similar to the trap call case except for the comment.
  8409.  
  8410. A special case is made for immediate byte operands with a nonzero high order
  8411. byte.  For example, the bytes $020011FF, when actually executed, would be
  8412. interpreted as ANDI.B $FF,D0. The processor will IGNORE the high order byte
  8413. of the immediate data! Thus, the bytes may be considered as valid.  Since the
  8414. Disassembler has no way of knowing the context in which it is disassembling,
  8415. it returns the Opcode as 'DC.W' as in the normal invalid case.  However, the
  8416. Operand string shows ALL the words disassembled separated with commas and
  8417. places the possibly valid disassembly in the Operand's comment indicating the
  8418. nonzero bytes. Thus for the example $020011FF bytes, the Opcode will be
  8419. 'DC.W', the Operand will be '$0200,$11FF', and the Comment 
  8420. '; ANDI.B #$??FF,D0'.  BytesUsed in this case would be 4.
  8421.  
  8422. Note, the Operand EA's is syntatically similar to but NOT COMPATIBLE with the
  8423. MPW assembler!  This is because the Disassembler generates byte hex constants
  8424. as "$XX" and word hex constants as "$XXXX".  Negative values (e.g., $FF or
  8425. $FFFF) produced by the Disassembler are treated as long word values by the MPW
  8426. assembler.  Thus it is assumed that Disassembler output will NOT be used as
  8427. MPW assembler input. If that is the goal, then the caller must convert strings
  8428. of the form $XX or $XXXX in the Operand string to their decimal equivalent.
  8429. The routine ModifyOperand is provided in this unit to aid with the conversion
  8430. process.
  8431.  
  8432. Since a PC-relative comment is an address, the only address that the
  8433. Disassembler knows about is the address of the code pointed to by FirstByte.
  8434. Generally, that may be a buffer that has no relation to "reality", i.e., the
  8435. actual code loaded into the buffer.  Therefore, to allow the address comment
  8436. to be mapped back to some actual address the caller may specify an adjustment
  8437. factor, specified by DstAdjust that is ADDED to the value that normally would
  8438. be placed in the comment.
  8439.  
  8440. Operand effective address strings are generated as a function of the 
  8441. effective address mode and a special case is made for A-trap opcode strings.
  8442. In places where a possible symbolic reference could be substituted for an
  8443. address (or a portion of an address), the Disassembler can call a user
  8444. specified routine to do the substitution (using th LookupProc parameter
  8445. described later).  The following table summarizes the generated effective
  8446. addresses and where symbolic substitutions (S) can be made:
  8447.      
  8448. Mode    Generated Effective Address  Effective Address with Substitution
  8449. ========================================================================
  8450.   0     Dn                           Dn
  8451.   1     An                           An
  8452.   2     (An)                         (An)
  8453.   3     (An)+                        (An)+
  8454.   4     -(An)                        -(An)
  8455.   5     ∂(An)                        S(An) or just S (if An=A5, ∂≥0)
  8456.  6n     ∂(An,Xn.Size*Scale)          S(An,Xn.Size*Scale)
  8457.  6n     (BD,An,Xn.Size*Scale)        (S,An,Xn.Size*Scale)
  8458.  6n     ([BD,An],Xm.Size*Scale,OD)   ([S,An],Xm.Size*Scale,OD)
  8459.  6n     ([BD,An,Xn.Size*Scale],OD)   ([S,An,Xn.Size*Scale],OD)
  8460.  70     ∂                            S
  8461.  71     ∂                            S
  8462.  72     *±∂                          S
  8463.  73     *±∂(Xn.Size*Scale)           S(Xn.Size*Scale)
  8464.  73     (*±∂,Xn.Size*Scale)          (S,Xn.Size*Scale)
  8465.  73     ([*±∂],Xm.Size*Scale,OD)     ([S],Xm.Size*Scale,OD)
  8466.  73     ([*±∂,Xn.Size*Scale],OD)     ([S,Xn.Size*Scale],OD)
  8467.  74     #data                        #data
  8468. ========================================================================
  8469.  
  8470. For A-traps, the substitution can be performed to substitute for the DC.W
  8471. opcode string.  If the substitution is made then the Disassembler will
  8472. generate ,Sys and/or ,Immed flags as operands for Toolbox traps and
  8473. ,AutoPop for OS traps when the bits in the trap word indicates these
  8474. settings.
  8475.  
  8476.         |         Generated          |            Substituted
  8477.         | Opcode  Operand  Comment   | Opcode  Operand        Comment
  8478. ========================================================================
  8479. Toolbox | DC.W    $AXXX    ; TB XXXX | S       [,Sys][,Immed] ; AXXX
  8480. OS      | DC.W    $AXXX    ; OS XXXX | S       [,AutoPop]     ; AXXX
  8481. ========================================================================
  8482.  
  8483. All displacements (∂, BD, OD) are hexadecimal values shown as a byte ($XX),
  8484. word ($XXXX), or long ($XXXXXXXX) as appropriate. The *Scale is suppressed if
  8485. 1. The Size is W or L.  Note that effective address substitutions can only be
  8486. made for "∂(An)", "BD,An", and "*±∂" cases.
  8487.     
  8488. For all the effective address modes 5, 6n, 7n, and for A-traps, a coroutine (a
  8489. procedure) whose address is specified by the LookupProc parameter is called by
  8490. the Disassembler (if LookupProc is not NIL) to do the substitution (or A-trap
  8491. comment) with a string returned by the proc.  It is assumed that the proc
  8492. pointed to by LookupProc is a level 1 Pascal proc declared as follows:
  8493.  
  8494. PROCEDURE Lookup(     PC:      UNIV Ptr;        {Addr of extension/trap word}
  8495.                      BaseReg: LookupRegs;       {Base register/lookup mode  }
  8496.                      Opnd:    UNIV LongInt;     {Trap word, PC addr, disp.  }
  8497.                  VAR S:       DisAsmStr80);     {Returned substitution      }
  8498.  
  8499. where TYPE DisAsmStr80 = String[80];
  8500.   
  8501. or in C,
  8502.  
  8503. pascal void LookUp(Ptr         PC, 
  8504.                    LookupRegs  BaseReg, 
  8505.                    long        Opnd, 
  8506.                    char        *S); 
  8507.  
  8508. PC      = Pointer to instruction extension word or A-trap word in the
  8509.           buffer pointed to by the Disassembler's FirstByte parameter.
  8510.           
  8511. BaseReg = This determines the meaning of the Opnd value and supplies
  8512.           the base register for the "∂(An)", "BD,An", and "*±∂" cases.
  8513.           BaseReg may contain any one of the following values:
  8514.          
  8515.           _A0_   =  0 ==> A0
  8516.           _A1_   =  1 ==> A1
  8517.           _A2_   =  2 ==> A2
  8518.           _A3_   =  3 ==> A3
  8519.           _A4_   =  4 ==> A4
  8520.           _A5_   =  5 ==> A5
  8521.           _A6_   =  6 ==> A6
  8522.           _A7_   =  7 ==> A7
  8523.           _PC_   =  8 ==> PC-relative (special case)
  8524.           _ABS_  =  9 ==> Abs addr    (special case)
  8525.           _TRAP_ = 10 ==> Trap word   (special case)
  8526.           
  8527.           For absolute addressing (modes 70 and 71),  BaseReg contains _ABS_.
  8528.           For A-traps, BaseReg would contain _TRAP_.
  8529.  
  8530. Opnd    = The contents of this LongInt is determined by the BaseReg parameter
  8531.           just described.
  8532.        
  8533.           For BaseReg = _TRAP_ (A-traps):
  8534.               Opnd is the entire trap word. The high order 16 bits of Opnd are
  8535.               zero.
  8536.  
  8537.           For BaseReg = _ABS_  (absolute effective address):
  8538.               Opnd contains the (extended) 32-bit address specifed by the
  8539.               instruction's effective address.  Such addresses would generally
  8540.               be used to reference low memory globals on a Macintosh.
  8541.  
  8542.           For BaseReg = _PC_  (PC-relative effective address):
  8543.               Opnd contains the 32-bit address represented by "*±∂" adjusted
  8544.               by the Disassembler's DstAdjust parameter.
  8545.               
  8546.           For BaseReg = _An_  (effective address with a base register):
  8547.               Opnd contains the (sign-extended) 32-bit (base) displacement
  8548.               from the instruction's effective address.
  8549.               
  8550.               In the Macintosh environment, a BaseReg specifying A5 implies
  8551.               either global data references or Jump Table references. Positive
  8552.               Opnd values with an A5 BaseReg thus mean Jump Table references,
  8553.               while a negative offset would mean a global data reference.
  8554.               Base registers of A6 or A7 would usually mean local data.
  8555.  
  8556. S       = Pascal string returned from Lookup containing the effective address
  8557.           substitution string or a trap name for A-traps.  S is set to null
  8558.           PRIOR to calling Lookup.  If it is still null on return, the string
  8559.           is not used.  If not null, then for A-traps, the returned string is
  8560.           used as a opcode string. In all other cases the string is
  8561.           substituted as shown in the above table.
  8562.            
  8563. Depending on the application, the caller has three choices on how to use the
  8564. Disassembler and an associated Lookup proc:
  8565.  
  8566. (1). The caller can call just the Disassembler and provide his own Lookup
  8567.      proc. In that case the calling conventions discussed above must be
  8568.      followed.
  8569.  
  8570. (2). The caller can provide NIL for the LookupProc parameter, in which case,
  8571.      NO Lookup proc will be called.
  8572.      
  8573. (3). The caller can call first InitLookup (described below, a proc provided
  8574.      with this unit) and pass the address of this unit's standard Lookup proc
  8575.      when Disassembler is called.  In this case all the control logic to
  8576.      determine the kind of substitution to be done is provided for the caller
  8577.      and all that need to be provided by the user are routines to look up any
  8578.      or all of the following:
  8579.      
  8580.      • PC-relative references
  8581.      • Jump Table references
  8582.      • Absolute address references
  8583.      • Trap names
  8584.      • References with offsets from base registers 
  8585. *)
  8586.  
  8587. æKY endOfModule
  8588. æFp DisAsmLookup.p
  8589. æT FUNCTION
  8590. æD FUNCTION endOfModule(address: UNIV Ptr;limit: UNIV Ptr;symbol: StringPtr;
  8591.     VAR nextModule: UNIV Ptr): StringPtr; C;
  8592. æDT myVariable := endOfModule(address,limit,symbol,nextModule);
  8593. æC 
  8594. { Check to see if the specified memory address contains a RTS, JMP (A0) or
  8595. RTD #n instruction immediately followed by a valid MacsBug symbol.  These
  8596. sequences are the only ones which can determine an end of module when MacsBug
  8597. symbols are present.  During the check, the instruction and its following
  8598. MacsBug symbol must be fully contained in the bytes starting at the specified
  8599. address parameter, up to, but not including, the byte pointed to by the limit
  8600. parameter.
  8601.  
  8602. If the end of module is NOT found, then NULL is returned as the function's
  8603. result.  However, if a end of module is found, the MacsBug symbol is returned
  8604. in symbol (if it is not NULL) as a null terminated Pascal string (with trailing
  8605. blanks removed), and the functions returns the pointer to the start of the
  8606. MacsBug symbol (i.e., address+2 for RTS or JMP (A0) and address+4 for RTD #n).
  8607. This address may then be used as in input parameter to showMacsBugSymbol to
  8608. convert the MacsBug symbol to a Disassembler operand string.
  8609.  
  8610. Also returned in nextModule is where we think the FOLLOWING module begins. In
  8611. the "old style" cases (see validMacsBugSymbol) this will always be 8 or 16
  8612. bytes after the input address.  For new style the Apple Pascal and C cases this
  8613. will depend on the symbol length, existence of a pad byte, and size of the
  8614. constant (literal) area.  See validMacsBugSymbol for a description of valid
  8615. MacsBug symbol formats. 
  8616.  }
  8617.  
  8618. æKY InitLookup
  8619. æFp DisAsmLookup.p
  8620. æT PROCEDURE
  8621. æD PROCEDURE InitLookup(PCRelProc: UNIV Ptr;JTOffProc: UNIV Ptr;TrapProc: UNIV Ptr;
  8622.     AbsAddrProc: UNIV Ptr;IdProc: UNIV Ptr);
  8623. æDT InitLookup(PCRelProc,JTOffProc,TrapProc,AbsAddrProc,IdProc);
  8624. æC 
  8625. { Prepare for use of this unit's Lookup proc.  When Disassembler is called
  8626. and the address of this unit's Lookup proc is specified, then for PC-relative,
  8627. Jump Table references, A-traps, absolute addresses, and offsets from a base
  8628. register, the associated level 1 Pascal proc specified here is called (if not
  8629. NULL -- all five addresses are preset to NULL). The calls assume the following
  8630. declarations for these procs (see Lookup, below for further details):
  8631.                              
  8632. PROCEDURE PCRelProc(Address: UNIV LongInt; 
  8633.                     VAR S:   UNIV DisAsmStr80);
  8634.  
  8635. PROCEDURE JTOffProc(A5JTOffset: UNIV Integer;
  8636.                     VAR S:      UNIV DisAsmStr80);
  8637.  
  8638. PROCEDURE TrapNameProc(TrapWord: UNIV Integer;
  8639.                        VAR S:     UNIV DisAsmStr80);
  8640.                         
  8641. PROCEDURE AbsAddrProc(AbsAddr: UNIV LongInt;
  8642.                       VAR S:   UNIV DisAsmStr80);
  8643.  
  8644. PROCEDURE IdProc(BaseReg: LookupRegs;
  8645.                  Offset:  UNIV LongInt;
  8646.                  VAR S:    UNIV DisAsmStr80);
  8647.  
  8648. or in C,
  8649.  
  8650. pascal void PCRelProc(long Address, char *S)
  8651.  
  8652. pascal void JTOffProc(short A5JTOffset, char *S)
  8653.  
  8654. pascal void TrapNameProc(unsigned short TrapWord, char *S)
  8655.  
  8656. pascal void AbsAddrProc(long AbsAddr, char *S)
  8657.  
  8658. pascal void IdProc(LookupRegs BaseReg, long Offset, char *S)
  8659.  
  8660. Note: InitLookup contains initialized data which requires initializing at load
  8661.       time (this is of concern only to users with assembler main programs.
  8662.  }
  8663.  
  8664. æKY Lookup
  8665. æFp DisAsmLookup.p
  8666. æT PROCEDURE
  8667. æD PROCEDURE Lookup(PC: UNIV Ptr;BaseReg: LookupRegs;Opnd: UNIV LongInt;
  8668.     VAR S: DisAsmStr80);
  8669. æDT Lookup(PC,BaseReg,Opnd,S);
  8670. æC 
  8671. { This is a standard Lookup proc available to the caller for calls to the
  8672. Disassembler.  If the caller elects to use this proc, then InitLookup MUST be
  8673. called prior to any calls to the Disassembler.  All the logic to determine the
  8674. type of lookup is done by this proc.  For PC-relative, Jump Table references,
  8675. A-traps, absolute addresses, and offsets from a base register, the associated
  8676. level 1 Pascal proc specified in the InitLookup call (if not NULL) is called.
  8677.  
  8678. This scheme simplifies the Lookup mechanism by allowing the caller to deal
  8679. with just the problems related to the application.
  8680.  }
  8681.  
  8682. æKY LookupRegs,_A0_,_A1_,_A2_,_A3_,_A4_,_A5_,_A6_,_A7_,_PC_,_ABS_,_TRAP_
  8683. æFp DisAsmLookup.p
  8684. æC LookupRegs = (_A0_,_A1_,_A2_,_A3_,_A4_,_A5_,_A6_,_A7_,_PC_,_ABS_,_TRAP_);
  8685.  
  8686. æKY LookupTrapName
  8687. æFp DisAsmLookup.p
  8688. æT PROCEDURE
  8689. æD PROCEDURE LookupTrapName(TrapWord: UNIV Integer;VAR S: UNIV DisAsmStr80);
  8690. æDT LookupTrapName(TrapWord,S);
  8691. æC 
  8692. { This is a procedure provided to allow conversion of a trap instruction (in
  8693.  TrapWord) to its corresponding trap name (in S).  It is provided primarily for
  8694.  use with the Disassembler and its address may be passed to InitLookup above for
  8695.  use by this unit's Lookup routine.  Alternatively, there is nothing prohibiting
  8696.  the caller from using it directly for other purposes or by some other lookup
  8697.  proc.
  8698.  
  8699. Note: The tables in this proc make the size of this proc about 9500 bytes.  The
  8700.      trap names are fully spelled out in upper and lower case.
  8701.  }
  8702.  
  8703. æKY ModifyOperand
  8704. æFp DisAsmLookup.p
  8705. æT PROCEDURE
  8706. æD PROCEDURE ModifyOperand(VAR Operand: UNIV DisAsmStr80);
  8707. æDT ModifyOperand(Operand);
  8708. æC 
  8709. { Scan an operand string, i.e., the null terminated Pascal string returned by
  8710. the Disassembler (null MUST be present here) and modify negative hex values to
  8711. negated positive value. For example, $FFFF(A5) would be modified to -$0001(A5).
  8712. The operand to be processed is  passed as the function's parameter which is
  8713. edited "in place" and returned to the caller.
  8714.  
  8715. This routine is essentially a pattern matcher and attempts to only modify 2, 4,
  8716. and 8 digit hex strings in the operand that "might" be offsets from a base
  8717. register.  If the matching tests are passed, the same number of original digits
  8718. are output (because that indicates a value's size -- byte, word, or long).
  8719.  
  8720. For a hex string to be modified, the following tests must be passed:
  8721.  
  8722. • There must have been exactly 2, 4, or 8 digits.
  8723.  
  8724.   Only hex strings $XX, $XXXX, and $XXXXXXXX are possible candidates because
  8725.   that is the only way the Disassembler generates offsets.
  8726.  
  8727. • Hex string must be delimited by a "(" or a ",".
  8728.  
  8729.   The "(" allows offsets for $XXXX(An,...) and $XX(An,Xn) addressing modes.
  8730.   The comma allows for the MC68020 addressing forms.
  8731.  
  8732. • The "$X..." must NOT be preceded by a "±".
  8733.  
  8734.   This eliminates the possibility of modifying the offset of a PC-relative
  8735.   addressing mode always generated in the form "*±$XXXX".
  8736.  
  8737. • The "$X..." must NOT be preceded by a "#".
  8738.  
  8739.   This eliminates modifying immediate data.
  8740.  
  8741. • Value must be negative.
  8742.  
  8743.   Negative values are the only values we modify.  A value $FFFF is modified to
  8744.   -$0001.
  8745.  }
  8746.  
  8747. æKY showMacsBugSymbol
  8748. æFp DisAsmLookup.p
  8749. æT FUNCTION
  8750. æD FUNCTION showMacsBugSymbol(symStart: UNIV Ptr;limit: UNIV Ptr;operand: StringPtr;
  8751.     VAR bytesUsed: INTEGER): StringPtr; C;
  8752. æDT myVariable := showMacsBugSymbol(symStart,limit,operand,bytesUsed);
  8753. æC 
  8754. { Format a MacsBug symbol as a operand of a DC.B directive.  The first one or two
  8755. bytes of the symbol are generated as $80+'c' if they have there high high bits
  8756. set.  All other characters are shown as characters in a string constant.  The
  8757. pad byte, if present, is one is also shown as $00.
  8758.  
  8759. This routine is called to check that the bytes pointed to by symStart represent
  8760. a valid MacsBug symbol.  The symbol must be fully contained in the bytes
  8761. starting at symStart, up to, but not including the byte pointed to by the limit
  8762. parameter.
  8763.  
  8764. When called, showMacsBugSymbol assumes that symStart is pointing at a valid
  8765. MacsBug symbol as validated by the validMacsBugSymbol or endOfModule routines.
  8766. As with validMacsBugSymbol, the symbol must be fully contained in the bytes
  8767. starting at symStart up to, but not including, the byte pointed to by the end
  8768. parameter.
  8769.  
  8770. The string is returned in the 'operand' parameter as a null terminated Pascal
  8771. string.  The function also returns a pointer to this string as its return
  8772. value (NULL is returned only if the byte pointed to by the limit parameter is
  8773. reached prior to processing the entire symbol -- which should not happen if
  8774. properly validated).  The number of bytes used for the symbol is returned in
  8775. bytesUsed.  Due to the way MacsBug symbols are encoded, bytesUsed may not
  8776. necessarily be the same as the length of the operand string.
  8777.  
  8778. A valid MacsBug symbol consists of the characters '_', '%', spaces, digits, and
  8779. upper/lower case letters in a format determined by the first two bytes of the
  8780. symbol as described in the validMacsBugSymbol routine.
  8781.  
  8782.  }
  8783.  
  8784. æKY validMacsBugSymbol
  8785. æFp DisAsmLookup.p
  8786. æT FUNCTION
  8787. æD FUNCTION validMacsBugSymbol(symStart: UNIV Ptr;limit: UNIV Ptr;symbol: StringPtr): StringPtr; C;
  8788. æDT myVariable := validMacsBugSymbol(symStart,limit,symbol);
  8789. æC 
  8790. { Check that the bytes pointed to by symStart represents a valid MacsBug symbol.
  8791. The symbol must be fully contained in the bytes starting at symStart, up to,
  8792. but not including, the byte pointed to by the limit parameter.
  8793.  
  8794. If a valid symbol is NOT found, then NULL is returned as the function's result.
  8795. However, if a valid symbol is found, it is copied to symbol (if it is not NULL)
  8796. as a null terminated Pascal string, and return a pointer to where we think the
  8797. FOLLOWING module begins. In the "old style" cases (see below) this will always
  8798. be 8 or 16 bytes after the input symStart.  For new style Apple Pascal and C
  8799. cases this will depend on the symbol length, existence of a pad byte, and size
  8800. of the constant (literal) area.  In all cases, trailing blanks are removed from
  8801. the symbol.
  8802.  
  8803. A valid MacsBug symbol consists of the characters '_', '%', spaces, digits, and
  8804. upper/lower case letters in a format determined by the first two bytes of the
  8805. symbol as follows:
  8806.  
  8807.  1st byte  | 2nd byte  |  Byte  |
  8808.    Range   |  Range    | Length | Comments
  8809. ==============================================================================
  8810.  $20 - $7F | $20 - $7F |    8   | "Old style" MacsBug symbol format
  8811.  $A0 - $FF | $20 - $7F |    8   | "Old style" MacsBug symbol format
  8812. ------------------------------------------------------------------------------
  8813.  $20 - $7F | $80 - $FF |   16   | "Old style" MacApp symbol ab==>b.a
  8814.  $A0 - $FF | $80 - $FF |   16   | "Old style" MacApp symbol ab==>b.a
  8815. ------------------------------------------------------------------------------
  8816.  $80       | $01 - $FF |    n   | n = 2nd byte       (Apple Compiler symbol)
  8817.  $81 - $9F | $00 - $FF |    m   | m = 1st byte & $7F (Apple Compiler symbol)
  8818. ==============================================================================
  8819.  
  8820. The formats are determined by whether bit 7 is set in the first and second
  8821. bytes.  This bit will removed when we find it or'ed into the first and/or
  8822. second valid symbol characters.
  8823.  
  8824. The first two formats in the above table are the basic "old style" (pre-
  8825. existing) MacsBug formats. The first byte may or may not have bit 7 set the
  8826. second byte is a valid symbol character.  The first byte (with bit 7 removed)
  8827. and the next 7 bytes are assumed to comprise the symbol.
  8828.  
  8829. The second pair of formats are also "old style" formats, but used for MacApp
  8830. symbols.  Bit 7 set in the second character indicates these formats. The symbol
  8831. is assumed to be 16 bytes with the second 8 bytes preceding the first 8 bytes
  8832. in the generated symbol.  For example, 12345678abcdefgh represents the symbol
  8833. abcdefgh.12345678.
  8834.  
  8835. The last pair of formats are reserved by Apple and generated by the MPW Pascal
  8836. and C compilers.  In these cases the value of the first byte is always between
  8837. $80 and $9F, or with bit 7 removed, between $00 and $1F.  For $00, the second
  8838. byte is the length of the symbol with that many bytes following the second
  8839. byte (thus a max length of 255). Values $01 to $1F represent the length itself.
  8840. A pad byte may follow these variable length cases if the symbol does not end
  8841. on a word boundary.  Following the symbol and the possible pad byte is a word
  8842. containing the size of the constants (literals) generated by the compiler.
  8843.  
  8844. Note that if symStart actually does point to a valid MacsBug symbol, then you
  8845. may use showMacsBugSymbol to convert the MacsBug symbol bytes to a string that
  8846. could be used as a DC.B operand for disassembly purposes.  This string
  8847. explicitly shows the MacsBug symbol encodings. }
  8848.  
  8849.  
  8850. æKY DiskInit.p
  8851. æKL DIBadMount
  8852. DIFormat
  8853. DILoad
  8854. DIUnload
  8855. DIVerify
  8856. DIZero
  8857.  
  8858. HFSDefaults
  8859.  
  8860. æKY DIBadMount
  8861. æFp DiskInit.p
  8862. æT FUNCTION
  8863. æTN $A9E9
  8864. æD FUNCTION DIBadMount(where: Point;evtMessage: LONGINT): INTEGER;
  8865. æDT myVariable := DIBadMount(where,evtMessage);
  8866. æC 
  8867. Assembly-language note:  The trap macro for the Disk Initialization Package
  8868.                          is _Pack2. The routine selectors are as follows:
  8869.  
  8870.                            diBadMount  .EQU    0
  8871.                            diLoad      .EQU    2
  8872.                            diUnload    .EQU    4
  8873.                            diFormat    .EQU    6
  8874.                            diVerify    .EQU    8
  8875.                            diZero      .EQU    10
  8876.  
  8877. Call DIBadMount when a disk-inserted event occurs if the result code in the high-order
  8878. word of the associated event message indicates an error (that is, the result code is
  8879. other than noErr). Given the event message in evtMessage, DIBadMount evaluates the
  8880. result code and either ejects the disk or lets the user initialize and name it. The
  8881. low-order word of the event message contains the drive number. The where parameter
  8882. specifies the location (in global coordinates) of the top left corner of the dialog
  8883. box displayed by DIBadMount.
  8884.  
  8885. If the result code passed is extFSErr, memFullErr, nsDrvErr, paramErr, or volOnLinErr,
  8886. DIBadMount simply ejects the disk from the drive and returns the result code. If the
  8887. result code ioErr, badMDBErr, or noMacDskErr is passed, the error can be corrected by
  8888. initializing the disk; DIBadMount displays a dialog box that describes the problem
  8889. and asks whether the user wants to initialize the disk. For the result code ioErr,
  8890. the dialog box shown in Figure 1 is displayed. (This happens if the disk is brand
  8891. new.) For badMDBErr and noMacDskErr, DIBadMount displays a similar dialog box in
  8892. which the description of the problem is “This disk is damaged” and “This is not a
  8893. Macintosh disk”, respectively.
  8894.  
  8895. •••Refer to Figure 1.•••
  8896.  
  8897. Figure 1–Disk Initialization Dialog for IOErr
  8898.  
  8899. Note:  Before presenting the disk initialization dialog, DIBadMount checks
  8900.        whether the drive contains an already mounted volume; if so, it ejects
  8901.        the disk and returns 2 as its result. This will happen rarely and may
  8902.        reflect an error in your program (for example, you forgot to call
  8903.        DILoad and the user had to switch to the disk containing the system
  8904.        resource file).
  8905.  
  8906. If the user responds to the disk initialization dialog by clicking the Eject button,
  8907. DIBadMount ejects the disk and returns 1 as its result. If the Initialize button is
  8908. clicked, a box displaying the message “Initializing
  8909. disk...” appears, and DIBadMount attempts to initialize the disk. If initialization
  8910. fails, the disk is ejected and the user is informed as shown in Figure 2; after the
  8911. user clicks OK, DIBadMount returns a negative result code ranging from firstDskErr to
  8912. lastDskErr, indicating that a low-level disk error occurred.
  8913.  
  8914. •••Refer to Figure 2.•••
  8915.  
  8916. Figure 2–Initialization Failure Dialog
  8917.  
  8918. If the disk is successfully initialized, the dialog box in Figure 3 appears. After
  8919. the user names the disk and clicks OK, DIBadMount mounts the volume by calling the
  8920. File Manager function MountVol and returns MountVol’s result code
  8921. (noErr if no error occurs).
  8922.  
  8923. •••Refer to Figure 3.•••
  8924.  
  8925. Figure 3–Dialog for Naming a Disk
  8926.  
  8927. Result codes    noErr               No error
  8928.                 extFSErr            External file system
  8929.                 memFullErr          Not enough room in heap zone
  8930.                 nsDrvErr            No such drive
  8931.                 paramErr            Bad drive number
  8932.                 volOnLinErr         Volume already on-line
  8933.                 firstDskErr         Low-level disk error
  8934.                 through lastDskErr
  8935.  
  8936. Other results   1                   User clicked Eject
  8937.                 2                   Mounted volume in drive
  8938.  
  8939. æKY DIFormat
  8940. æFp DiskInit.p
  8941. æT FUNCTION
  8942. æTN $A9E9
  8943. æD FUNCTION DIFormat(drvNum: INTEGER): OSErr;
  8944. æDT myVariable := DIFormat(drvNum);
  8945. æMM   
  8946. æRI DIFormat function  II-398
  8947. æC 
  8948. Assembly-language note:  The trap macro for the Disk Initialization Package
  8949.                          is _Pack2. The routine selectors are as follows:
  8950.  
  8951.                            diBadMount  .EQU    0
  8952.                            diLoad      .EQU    2
  8953.                            diUnload    .EQU    4
  8954.                            diFormat    .EQU    6
  8955.                            diVerify    .EQU    8
  8956.                            diZero      .EQU    10
  8957.  
  8958. DIFormat formats the disk in the drive specified by the given drive number and returns
  8959. a result code indicating whether the formatting was completed successfully or failed.
  8960. Formatting a disk consists of writing special information onto it so that the Disk
  8961. Driver can read from and write to the disk.
  8962.  
  8963. Result codes    noErr               No error
  8964.                 firstDskErr         Low-level disk error
  8965.                 through lastDskErr
  8966.  
  8967. æKY DILoad
  8968. æFp DiskInit.p
  8969. æT PROCEDURE
  8970. æTN $A9E9
  8971. æD PROCEDURE DILoad;
  8972. æDT DILoad;
  8973. æMM   
  8974. æRI DILoad procedure  II-396
  8975. æC 
  8976. Assembly-language note:  The trap macro for the Disk Initialization Package
  8977.                          is _Pack2. The routine selectors are as follows:
  8978.  
  8979.                            diBadMount  .EQU    0
  8980.                            diLoad      .EQU    2
  8981.                            diUnload    .EQU    4
  8982.                            diFormat    .EQU    6
  8983.                            diVerify    .EQU    8
  8984.                            diZero      .EQU    10
  8985.  
  8986. DILoad reads the Disk Initialization Package, and its associated dialog and dialog
  8987. items, from the system resource file into memory and makes them unpurgeable.
  8988.  
  8989. Note:  DIFormat, DIVerify, and DIZero don’t need the dialog, so if you use
  8990.        only these routines you can call the Resource Manager function
  8991.        GetResource to read just the package resource into memory (and
  8992.        the Memory Manager procedure HNoPurge to make it unpurgeable).
  8993.  
  8994. æKY DIUnload
  8995. æFp DiskInit.p
  8996. æT PROCEDURE
  8997. æTN $A9E9
  8998. æD PROCEDURE DIUnload;
  8999. æDT DIUnload;
  9000. æMM   
  9001. æRI DIUnload procedure  II-396
  9002. æC  
  9003. Assembly-language note:  The trap macro for the Disk Initialization Package
  9004.                          is _Pack2. The routine selectors are as follows:
  9005.  
  9006.                            diBadMount  .EQU    0
  9007.                            diLoad      .EQU    2
  9008.                            diUnload    .EQU    4
  9009.                            diFormat    .EQU    6
  9010.                            diVerify    .EQU    8
  9011.                            diZero      .EQU    10
  9012.  
  9013. DIUnload makes the Disk Initialization Package (and its associated dialog and dialog
  9014. items) purgeable.
  9015.  
  9016. æKY DIVerify
  9017. æFp DiskInit.p
  9018. æT FUNCTION
  9019. æTN $A9E9
  9020. æD FUNCTION DIVerify(drvNum: INTEGER): OSErr;
  9021. æDT myVariable := DIVerify(drvNum);
  9022. æMM   
  9023. æRI DIVerify function  II-398
  9024. æC 
  9025. Assembly-language note:  The trap macro for the Disk Initialization Package
  9026.                          is _Pack2. The routine selectors are as follows:
  9027.  
  9028.                            diBadMount  .EQU    0
  9029.                            diLoad      .EQU    2
  9030.                            diUnload    .EQU    4
  9031.                            diFormat    .EQU    6
  9032.                            diVerify    .EQU    8
  9033.                            diZero      .EQU    10
  9034.  
  9035. DIVerify verifies the format of the disk in the drive specified by the given drive
  9036. number; it reads each bit from the disk and returns a result code indicating whether
  9037. all bits were read successfully or not. DIVerify doesn’t affect the contents of the
  9038. disk itself.
  9039.  
  9040. Result codes    noErr               No error
  9041.                 firstDskErr         Low-level disk error
  9042.                 through lastDskErr
  9043.  
  9044. æKY DIZero
  9045. æFp DiskInit.p
  9046. æT FUNCTION
  9047. æTN $A9E9
  9048. æD FUNCTION DIZero(drvNum: INTEGER;volName: Str255): OSErr;
  9049. æDT myVariable := DIZero(drvNum,volName);
  9050. æMM 
  9051. æRT 70
  9052. æRI DIZero function  II-399, N70-2
  9053. æC 
  9054. Assembly-language note:  The trap macro for the Disk Initialization Package
  9055.                          is _Pack2. The routine selectors are as follows:
  9056.  
  9057.                            diBadMount  .EQU    0
  9058.                            diLoad      .EQU    2
  9059.                            diUnload    .EQU    4
  9060.                            diFormat    .EQU    6
  9061.                            diVerify    .EQU    8
  9062.                            diZero      .EQU    10
  9063.  
  9064. On the unmounted volume in the drive specified by the given drive number, DIZero
  9065. writes the volume information, a block map, and a file directory as for a volume with
  9066. no files; the volName parameter specifies the volume name to be included in the
  9067. volume information. This is the last step in initialization
  9068. (after formatting and verifying) and makes any files that are already on the volume
  9069. permanently inaccessible. If the operation fails, DIZero returns a result code indicating
  9070. that a low-level disk error occurred; otherwise, it mounts the volume by calling the
  9071. File Manager function MountVol and returns MountVol’s result code (noErr if no error
  9072. occurs).
  9073.  
  9074. Result codes    noErr              No error
  9075.                 badMDBErr          Bad master directory block
  9076.                 extFSErr           External file system
  9077.                 ioErr              I/O error
  9078.                 memFullErr         Not enough room in heap zone
  9079.                 noMacDskErr        Not a Macintosh disk
  9080.                 nsDrvErr           No such drive
  9081.                 paramErr           Bad drive number
  9082.                 volOnLinErr        Volume already on-line
  9083.                 firstDskErr        Low-level disk error
  9084.                 through lastDskErr
  9085.  
  9086. æKY HFSDefaults
  9087. æFp DiskInit.p
  9088. æT RECORD
  9089. æC HFSDefaults = RECORD
  9090.    sigWord: PACKED ARRAY [0..1] OF Byte;   { signature word}
  9091.    abSize: LONGINT;                        { allocation block size in bytes}
  9092.    clpSize: LONGINT;                       { clump size in bytes}
  9093.    nxFreeFN: LONGINT;                      { next free file number}
  9094.    btClpSize: LONGINT;                     { B-Tree clump size in bytes}
  9095.    rsrv1: INTEGER;                         { reserved}
  9096.    rsrv2: INTEGER;                         { reserved}
  9097.    rsrv3: INTEGER;                         { reserved}
  9098.    END;
  9099.  
  9100.  
  9101. »Formatting Hierarchical Volumes
  9102.  
  9103. The Disk Initialization Package must set certain volume characteristics when placing
  9104. a hierarchical file directory on a volume. Default values for these volume characteristics
  9105. are stored in the 128K ROM; this section is for advanced programmers who want to
  9106. substitute their own values. The record containing the default values, if defined in
  9107. Pascal, would look like this:
  9108.  
  9109. TYPE  HFSDefaults = PACKED RECORD
  9110.                       sigWord:    ARRAY[1..2] OF CHAR;    {signature word}
  9111.                       abSize:     LONGINT;    {allocation block size in bytes}
  9112.                       clpSize:    LONGINT;    {clump size in bytes}
  9113.                       nxFreeFN:   LONGINT;    {next free file number}
  9114.                       btClpSize:  LONGINT;    {B*-Tree clump size in bytes}
  9115.                       rsrv1:      INTEGER;    {reserved}
  9116.                       rsrv2:      INTEGER;    {reserved}
  9117.                       rsrv3:      INTEGER;    {reserved}
  9118.                     END;
  9119.  
  9120. The default values for these fields are as follows:
  9121.  
  9122.   Field    Default value
  9123.  
  9124.   sigWord     'BD'
  9125.   abSize       0
  9126.   clpSize      4 * abSize
  9127.   nxFreeFN    16
  9128.   btClpSize    0
  9129.  
  9130. To supply your own values for these fields, create a similar, nonrelocatable record
  9131. containing the desired values and place a pointer to it in the global variable FmtDefaults.
  9132. To restore the system defaults, simply clear FmtDefaults.
  9133.  
  9134. The sigWord must equal 'BD' (meaning “big disk”) for the volume to be recognized as a
  9135. hierarchical volume. If the specified allocation block size is 0, the allocation
  9136. block size is calculated according to the size of the volume:
  9137.  
  9138.   abSize = (1 + (volSize in blocks / 64K)) * 512 bytes
  9139.  
  9140. If the specified B*-tree clump size is 0, the clump size for both the catalog and
  9141. extent trees is calculated according to the size of the volume:
  9142.  
  9143.   btClpSize = (volSize in blocks)/128 * 512bytes
  9144.  
  9145. æKY Disks.p
  9146. æKL DiskEject
  9147. DriveStatus
  9148. SetTagBuffer
  9149.  
  9150. DrvSts
  9151.  
  9152. æKY DiskEject
  9153. æFp Disks.p
  9154. æT FUNCTION
  9155. æD FUNCTION DiskEject(drvNum: INTEGER): OSErr;
  9156. æDT myVariable := DiskEject(drvNum);
  9157. æMM   
  9158. æRI DiskEject function  II-214
  9159. æC 
  9160. [Not in ROM]
  9161.  
  9162. Assembly-language note:  DiskEject is equivalent to a Control call with
  9163.                          csCode equal to the global constant ejectCode.
  9164.  
  9165. DiskEject ejects the disk from the internal drive if drvNum is 1, or from the external
  9166. drive if drvNum is 2.
  9167.  
  9168. Result codes    noErr       No error
  9169.                 nsDrvErr    No such drive
  9170.  
  9171. æKY DriveStatus
  9172. æFp Disks.p
  9173. æT FUNCTION
  9174. æD FUNCTION DriveStatus(drvNum: INTEGER;VAR status: DrvSts): OSErr;
  9175. æDT myVariable := DriveStatus(drvNum,status);
  9176. æMM   
  9177. æRI DriveStatus function  II-215
  9178. æC 
  9179. [Not in ROM]
  9180.  
  9181. Assembly-language note:  DriveStatus is equivalent to a Status call with
  9182.                          csCode equal to the global constant drvStsCode;
  9183.                          status is returned in csParam through csParam+21.
  9184.  
  9185. DriveStatus returns information about the internal drive if drvNum is 1, or about the
  9186. external drive if drvNum is 2. The information is returned in a record of type DrvSts:
  9187.  
  9188. TYPE  DrvSts = RECORD
  9189.                  track:        INTEGER;     {current track}
  9190.                  writeProt:    SignedByte;  {bit 7=1 if volume is locked}
  9191.                  diskInPlace:  SignedByte;  {disk in place}
  9192.                  installed:    SignedByte;  {drive installed}
  9193.                  sides:        SignedByte;  {bit 7=0 if single-side drive}
  9194.                  qLink:        QElemPtr;    {next queue entry}
  9195.                  qType:        INTEGER;     {reserved for future use}
  9196.                  dQDrive:      INTEGER;     {drive number}
  9197.                  dQRefNum:     INTEGER;     {driver reference number}
  9198.                  dQFSID:       INTEGER;     {file-system identifier}
  9199.                  twoSideFmt:   SignedByte;  {-1 if two-sided disk}
  9200.                  needsFlush:   SignedByte;  {reserved for future use}
  9201.                  diskErrs:     INTEGER      {error count}
  9202.                END;
  9203.  
  9204. The diskInPlace field is 0 if there’s no disk in the drive, 1 or 2 if there is a disk
  9205. in the drive, or –4 to –1 if the disk was ejected in the last 1.5 seconds. The installed
  9206. field is 1 if the drive is connected to the Macintosh, 0 if the drive might be connected
  9207. to the Macintosh, and –1 if the drive isn’t installed. The value of twoSideFmt is
  9208. valid only when diskInPlace=2. The value of diskErrs is incremented every time an
  9209. error occurs internally within the Disk Driver.
  9210.  
  9211. Result codes    noErr       No error
  9212.                 nsDrvErr    No such drive
  9213.  
  9214. æKY DrvSts
  9215. æFp Disks.p
  9216. æT RECORD
  9217. æC DrvSts = RECORD
  9218.    track: INTEGER;                 {current track}
  9219.    writeProt: SignedByte;          {bit 7 = 1 if volume is locked}
  9220.    diskInPlace: SignedByte;        {disk in drive}
  9221.    installed: SignedByte;          {drive installed}
  9222.    sides: SignedByte;              {-1 for 2-sided, 0 for 1-sided}
  9223.    driveQLink: QElemPtr;           {next queue entry}
  9224.    driveQVers: INTEGER;            {1 for HD20}
  9225.    dQDrive: INTEGER;               {drive number}
  9226.    dQRefNum: INTEGER;              {driver reference number}
  9227.    dQFSID: INTEGER;                {file system ID}
  9228.    CASE DriveKind OF
  9229.      sony:
  9230.        (twoSideFmt: SignedByte;    {after 1st rd/wrt: 0=1 side, -1=2 side}
  9231.        needsFlush: SignedByte;     {-1 for MacPlus drive}
  9232.        diskErrs: INTEGER);         {soft error count}
  9233.      hard20:
  9234.        (driveSize: INTEGER;        {drive block size low word}
  9235.        driveS1: INTEGER;           {drive block size high word}
  9236.        driveType: INTEGER;         {1 for HD20}
  9237.        driveManf: INTEGER;         {1 for Apple Computer, Inc.}
  9238.        driveChar: SignedByte;      {230 ($E6) for HD20}
  9239.        driveMisc: SignedByte);     {0 -- reserved}
  9240.    END;
  9241.  
  9242. æKY SetTagBuffer
  9243. æFp Disks.p
  9244. æT FUNCTION
  9245. æD FUNCTION SetTagBuffer(buffPtr: Ptr): OSErr;
  9246. æDT myVariable := SetTagBuffer(buffPtr);
  9247. æMM   
  9248. æRI SetTagBuffer function II-214
  9249. æC 
  9250. [Not in ROM]
  9251.  
  9252. Assembly-language note:  SetTagBuffer is equivalent to a Control call with
  9253.                          csCode equal to the global constant tgBuffCode.
  9254.  
  9255. An application can change the information used in the file tags buffer by calling
  9256. SetTagBuffer. The buffPtr parameter points to a buffer that contains the information
  9257. to be used. If buffPtr is NIL, the information in the file tags buffer isn’t changed.
  9258.  
  9259. If buffPtr isn’t NIL, every time the Disk Driver reads a sector from the disk, it
  9260. stores the file tags in the file tags buffer and in the buffer pointed to by buffPtr.
  9261. Every time the Disk Driver writes a sector onto the disk, it reads 12 bytes from the
  9262. buffer pointed to by buffPtr, places them in the file tags buffer, and then writes
  9263. them onto the disk.
  9264.  
  9265. The contents of the buffer pointed to by buffPtr are overwritten at the end of every
  9266. read request (which can be composed of a number of sectors) instead of at the end of
  9267. every sector. Each read request places 12 bytes in the buffer for each sector, always
  9268. beginning at the start of the buffer. This way an application can examine the file
  9269. tags for a number of sequentially read sectors. If a read request is composed of a
  9270. number of sectors, the Disk Driver places 12 bytes in the buffer for each sector. For
  9271. example, for a read request of five sectors, the Disk Driver will place 60 bytes in
  9272. the buffer.
  9273.  
  9274. Result codes    noErr    No error
  9275.  
  9276. æKY ErrMgr.p
  9277. æKL AddErrInsert
  9278. CloseErrMgr
  9279. GetSysErrText
  9280. GetToolErrText
  9281. InitErrMgr
  9282.  
  9283. æKY AddErrInsert
  9284. æFp ErrMgr.p
  9285. æT PROCEDURE
  9286. æD PROCEDURE AddErrInsert(insert: Str255;msgString: StringPtr); C;
  9287. æDT AddErrInsert(insert,msgString);
  9288. æC 
  9289. { Add another insert to an error message string.This call is used when more
  9290. than one insert is to be added to a message (because it contains more than
  9291. one '^' character).
  9292.  }
  9293.  
  9294. æKY CloseErrMgr
  9295. æFp ErrMgr.p
  9296. æT PROCEDURE
  9297. æD PROCEDURE CloseErrMgr; C;
  9298. æDT CloseErrMgr;
  9299. æC 
  9300. { Ideally a CloseErrMgr should be done at the end of execution to make sure all
  9301. files opened by the ErrMgr are closed.  You can let normal program termination
  9302. do the closing.  But if you are a purist...
  9303.  }
  9304.  
  9305. æKY GetSysErrText
  9306. æFp ErrMgr.p
  9307. æT PROCEDURE
  9308. æD PROCEDURE GetSysErrText(msgNbr: INTEGER;errMsg: StringPtr);
  9309. æDT GetSysErrText(msgNbr,errMsg);
  9310. æC 
  9311. (* Get the error message text corresponding to system error number errNbr from
  9312. the system error message file (whose name was specified in the InitErrMgr
  9313. call).  The text of the message is returned in errMsg and the function returns
  9314. a pointer to errMsg.  The maximum length of the message is limited to 254
  9315. characters.
  9316.  
  9317. Note, if a system message filename was not specified to InitErrMgr, then the
  9318. ErrMgr assumes the message file contained in the file "SysErrs.Err".  This
  9319. file is first accessed as "                                 {ShellDirectory}SysErrs.Err" on the assumption that
  9320. SysErrs.Err is kept in the same directory as the MPW Shell.  If the file
  9321. cannot be opened, then an open is attempted on "SysErrs.Err" in the System
  9322. Folder. *)
  9323.  
  9324. æKY GetToolErrText
  9325. æFp ErrMgr.p
  9326. æT PROCEDURE
  9327. æD PROCEDURE GetToolErrText(msgNbr: INTEGER;errInsert: Str255;errMsg: StringPtr);
  9328. æDT GetToolErrText(msgNbr,errInsert,errMsg);
  9329. æC 
  9330. (* Get the error message text corresponding to tool error number errNbr from
  9331. the tool error message file (whose name was specified in the InitErrMgr
  9332. call).  The text of the message is returned in errMsg and the function returns
  9333. a pointer to errMsg.  The maximum length of the message is limited to 254
  9334. characters.  If the message is to have an insert, then ErrInsert should be a
  9335. pointer to it.  Otherwise it should be either be a null string or a NULL
  9336. pointer.
  9337.  
  9338. Inserts are indicated in error messages by specifying a '^' to indicate where
  9339. the insert is to be placed.
  9340.  
  9341. Note, if a tool message filename was not specified to InitErrMgr, then the
  9342. ErrMgr assumes the message file contained in the data fork of the tool calling
  9343. the ErrMgr.  This name is contained in the Shell variable   {Command} and the
  9344. value of that variable is used to open the error message file. *)
  9345.  
  9346. æKY InitErrMgr
  9347. æFp ErrMgr.p
  9348. æT PROCEDURE
  9349. æD PROCEDURE InitErrMgr(toolErrFilename: Str255;sysErrFilename: Str255;
  9350.     showToolErrNbrs: BOOLEAN);
  9351. æDT InitErrMgr(toolErrFilename,sysErrFilename,showToolErrNbrs);
  9352. æC 
  9353. { ErrMgr initialization.This must be done before using any other ErrMgr
  9354. routine.  Set showToolErrNbrs to true if you want all tool messages to contain
  9355. the error number following the message text enclosed in parentheses (e.g.,
  9356. "<msg txt> ([OS] Error <n>)"; system error messages always contain the error 
  9357. number).  The toolErrFileName parameter is used to specify the name of a 
  9358. tool-specific error file, and should be the NULL or a null string if not used
  9359. (or if the tool's data fork is to be used as the error file, see
  9360. GetToolErrText for futher details). The sysErrFileName parameter is used to
  9361. specify the name of a system error file, and should normally be the NULL or a
  9362. null string, which causes the ErrMgr to look in the MPW Shell directory for
  9363. "SysErrs.Err" (see GetSysErrText). }
  9364.  
  9365.  
  9366. æKY Errors.p
  9367. æKL SysError
  9368.  
  9369. abortErr
  9370. addRefFailed
  9371. addResFailed
  9372. afpAccessDenied
  9373. afpAuthContinue
  9374. afpBadUAM
  9375. afpBadVersNum
  9376. afpBitmapErr
  9377. afpCallNotSupported
  9378. afpCantMove
  9379. afpCantRename
  9380. afpDenyConflict
  9381. afpDirNotEmpty
  9382. afpDirNotFound
  9383. afpDiskFull
  9384. afpEofError
  9385. afpFileBusy
  9386. afpFlatVol
  9387. afpIconTypeError
  9388. afpItemNotFound
  9389. afpLockErr
  9390. afpMiscErr
  9391. afpNoMoreLocks
  9392. afpNoServer
  9393. afpObjectExists
  9394. afpObjectLocked
  9395. afpObjectNotFound
  9396. afpObjectTypeErr
  9397. afpParmErr
  9398. afpRangeNotLocked
  9399. afpRangeOverlap
  9400. afpServerGoingDown
  9401. afpSessClosed
  9402. afpTooManyFilesOpen
  9403. afpUserNotAuth
  9404. afpVolLocked
  9405. aspBadVersNum
  9406. aspBufTooSmall
  9407. aspNoAck
  9408. aspNoMoreSess
  9409. aspNoServers
  9410. aspParamErr
  9411. aspServerBusy
  9412. aspSessClosed
  9413. aspSizeErr
  9414. aspTooMany
  9415. atpBadRsp
  9416. atpLenErr
  9417. badATPSkt
  9418. badBtSlpErr
  9419. badBuffNum
  9420. badChannel
  9421. badCksmErr
  9422. badDBtSlp
  9423. badDCksum
  9424. badFormat
  9425. badMDBErr
  9426. badMovErr
  9427. badUnitErr
  9428. bdNamErr
  9429. breakRecd
  9430. buf2SmallErr
  9431. cantStepErr
  9432. cbNotFound
  9433. cDevErr
  9434. ckSumErr
  9435. clkRdErr
  9436. clkWrErr
  9437. closErr
  9438. cMatchErr
  9439. cNoMemErr
  9440. controlErr
  9441. corErr
  9442. cProtectErr
  9443. cRangeErr
  9444. cResErr
  9445. cTempMemErr
  9446. dataVerErr
  9447. dceExtErr
  9448. ddpLenErr
  9449. ddpSktErr
  9450. dInstErr
  9451. dirFulErr
  9452. dirNFErr
  9453. dRemovErr
  9454. dsAddressErr
  9455. dsBadLaunch
  9456. dsBadPatch
  9457. dsBadSANEopcode
  9458. dsBadSlotInt
  9459. dsBusError
  9460. dsChkErr
  9461. dsCoreErr
  9462. dsFinderErr
  9463. dsFPErr
  9464. dsFSErr
  9465. dsGreeting
  9466. dsHMenuFindErr
  9467. dsIllInstErr
  9468. dsIOCoreErr
  9469. dsIrqErr
  9470. dskFulErr
  9471. dsLineAErr
  9472. dsLineFErr
  9473. dsLoadErr
  9474. dsMBarNFnd
  9475. dsMemFullErr
  9476. dsMiscErr
  9477. dsNoPackErr
  9478. dsNoPatch
  9479. dsNoPk1
  9480. dsNoPk2
  9481. dsNoPk3
  9482. dsNoPk4
  9483. dsNoPk5
  9484. dsNoPk6
  9485. dsNoPk7
  9486. dsNotThe1
  9487. dsOvflowErr
  9488. dsPrivErr
  9489. dsReinsert
  9490. dsStknHeap
  9491. dsSysErr
  9492. dsTraceErr
  9493. dsZeroDivErr
  9494. dupFNErr
  9495. envBadVers
  9496. envNotPresent
  9497. envVersTooBig
  9498. eofErr
  9499. evtNotEnb
  9500. excessCollsns
  9501. extFSErr
  9502. extractErr
  9503. exUserBreak
  9504. fBsyErr
  9505. firstDskErr
  9506. fLckdErr
  9507. fmt1Err
  9508. fmt2Err
  9509. fnfErr
  9510. fnOpnErr
  9511. fontDecError
  9512. fontNotDeclared
  9513. fontSubErr
  9514. framingErr
  9515. fsDSIntErr
  9516. fsRnErr
  9517. gcrOnMFMErr
  9518. gfpErr
  9519. hMenuFindErr
  9520. hwOverrunErr
  9521. hwParamErr
  9522. iIOAbortErr
  9523. initIWMErr
  9524. ioErr
  9525. lapProtErr
  9526. lastDskErr
  9527. mapReadErr
  9528. mBarNFnd
  9529. memAdrErr
  9530. memAZErr
  9531. memBCErr
  9532. memFullErr
  9533. memLockedErr
  9534. memPCErr
  9535. memPurErr
  9536. memROZErr
  9537. memROZWarn
  9538. memSCErr
  9539. memWZErr
  9540. menuPrgErr
  9541. mFulErr
  9542. nbpBuffOvr
  9543. nbpConfDiff
  9544. nbpDuplicate
  9545. nbpNISErr
  9546. nbpNoConfirm
  9547. nbpNotFound
  9548. negZcbFreeErr
  9549. nilHandleErr
  9550. nmTypErr
  9551. noAdrMkErr
  9552. noBridgeErr
  9553. noDataArea
  9554. noDriveErr
  9555. noDtaMkErr
  9556. noErr
  9557. noHardware
  9558. noMacDskErr
  9559. noMPPErr
  9560. noNybErr
  9561. noRelErr
  9562. noScrapErr
  9563. noSendResp
  9564. notEnoughHardware
  9565. notOpenErr
  9566. noTypeErr
  9567. nsDrvErr
  9568. nsvErr
  9569. offLinErr
  9570. openErr
  9571. opWrErr
  9572. paramErr
  9573. parityErr
  9574. permErr
  9575. portInUse
  9576. portNotCf
  9577. posErr
  9578. prInitErr
  9579. prWrErr
  9580. qErr
  9581. queueFull
  9582. rcvrErr
  9583. readErr
  9584. readQErr
  9585. recNotFnd
  9586. reqAborted
  9587. reqFailed
  9588. resAttrErr
  9589. resFNotFound
  9590. resNotFound
  9591. resProblem
  9592. rfNumErr
  9593. rgnTooBigErr
  9594. rmvRefFailed
  9595. rmvResFailed
  9596. sdmInitErr
  9597. sdmJTInitErr
  9598. sdmPRAMInitErr
  9599. sdmPriInitErr
  9600. sdmSRTInitErr
  9601. sectNFErr
  9602. seekErr
  9603. seNoDB
  9604. shutDownAlert
  9605. siInitSDTblErr
  9606. siInitSPTblErr
  9607. siInitVBLQsErr
  9608. sktClosedErr
  9609. slotNumErr
  9610. smBadBoardId
  9611. smBadRefId
  9612. smBadsList
  9613. smBadsPtrErr
  9614. smBLFieldBad
  9615. smBlkMoveErr
  9616. smBusErrTO
  9617. smByteLanesErr
  9618. smCkStatusErr
  9619. smCodeRevErr
  9620. smCPUErr
  9621. smCRCFail
  9622. smDisDrvrNamErr
  9623. smDisposePErr
  9624. smEmptySlot
  9625. smFHBlockRdErr
  9626. smFormatErr
  9627. smGetDrvrNamErr
  9628. smGetPRErr
  9629. smInitStatVErr
  9630. smInitTblErr
  9631. smLWTstBad
  9632. smNewPErr
  9633. smNilsBlockErr
  9634. smNoBoardId
  9635. smNoBoardsRsrc
  9636. smNoDir
  9637. smNoGoodOpens
  9638. smNoJmpTbl
  9639. smNoMoresRsrcs
  9640. smNosInfoArray
  9641. smOffsetErr
  9642. smPRAMInitErr
  9643. smPriInitErr
  9644. smRecNotFnd
  9645. smReservedErr
  9646. smResrvErr
  9647. smRevisionErr
  9648. smSDMInitErr
  9649. smSelOOBErr
  9650. smsGetDrvrErr
  9651. smSlotOOBErr
  9652. smsPointerNil
  9653. smSRTInitErr
  9654. smSRTOvrFlErr
  9655. smUnExBusErr
  9656. spdAdjErr
  9657. statusErr
  9658. strUserBreak
  9659. svDisabled
  9660. svTempDisable
  9661. swOverrunErr
  9662. teScrapSizeErr
  9663. tk0BadErr
  9664. tmfoErr
  9665. tmwdoErr
  9666. tooManyReqs
  9667. tooManySkts
  9668. twoSideErr
  9669. unimpErr
  9670. unitEmptyErr
  9671. unitTblFullErr
  9672. updPixMemErr
  9673. userBreak
  9674. verErr
  9675. vLckdErr
  9676. volGoneErr
  9677. volOffLinErr
  9678. volOnLinErr
  9679. vTypErr
  9680. wPrErr
  9681. wrgVolTypErr
  9682. writErr
  9683. wrPermErr
  9684. wrUnderrun
  9685.  
  9686.  
  9687. æKY abortErr
  9688. æFp Errors.p
  9689. æC abortErr = -27; {IO call aborted by KillIO}
  9690.  
  9691. æKY addRefFailed
  9692. æFp Errors.p
  9693. æC addRefFailed = -195; {AddReference failed}
  9694.  
  9695. æKY addResFailed
  9696. æFp Errors.p
  9697. æC addResFailed = -194; {AddResource failed}
  9698.  
  9699. æKY afpAccessDenied
  9700. æFp Errors.p
  9701. æC afpAccessDenied = -5000;
  9702.  
  9703. æKY afpAuthContinue
  9704. æFp Errors.p
  9705. æC afpAuthContinue = -5001;
  9706.  
  9707. æKY afpBadUAM
  9708. æFp Errors.p
  9709. æC afpBadUAM = -5002;
  9710.  
  9711. æKY afpBadVersNum
  9712. æFp Errors.p
  9713. æC afpBadVersNum = -5003;
  9714.  
  9715. æKY afpBitmapErr
  9716. æFp Errors.p
  9717. æC afpBitmapErr = -5004;
  9718.  
  9719. æKY afpCallNotSupported
  9720. æFp Errors.p
  9721. æC afpCallNotSupported = -5024;
  9722.  
  9723. æKY afpCantMove
  9724. æFp Errors.p
  9725. æC afpCantMove = -5005;
  9726.  
  9727. æKY afpCantRename
  9728. æFp Errors.p
  9729. æC afpCantRename = -5028;
  9730.  
  9731. æKY afpDenyConflict
  9732. æFp Errors.p
  9733. æC afpDenyConflict = -5006;
  9734.  
  9735. æKY afpDirNotEmpty
  9736. æFp Errors.p
  9737. æC afpDirNotEmpty = -5007;
  9738.  
  9739. æKY afpDirNotFound
  9740. æFp Errors.p
  9741. æC afpDirNotFound = -5029;
  9742.  
  9743. æKY afpDiskFull
  9744. æFp Errors.p
  9745. æC afpDiskFull = -5008;
  9746.  
  9747. æKY afpEofError
  9748. æFp Errors.p
  9749. æC afpEofError = -5009;
  9750.  
  9751. æKY afpFileBusy
  9752. æFp Errors.p
  9753. æC afpFileBusy = -5010;
  9754.  
  9755. æKY afpFlatVol
  9756. æFp Errors.p
  9757. æC afpFlatVol = -5011;
  9758.  
  9759. æKY afpIconTypeError
  9760. æFp Errors.p
  9761. æC afpIconTypeError = -5030;
  9762.  
  9763. æKY afpItemNotFound
  9764. æFp Errors.p
  9765. æC afpItemNotFound = -5012;
  9766.  
  9767. æKY afpLockErr
  9768. æFp Errors.p
  9769. æC afpLockErr = -5013;
  9770.  
  9771. æKY afpMiscErr
  9772. æFp Errors.p
  9773. æC afpMiscErr = -5014;
  9774.  
  9775. æKY afpNoMoreLocks
  9776. æFp Errors.p
  9777. æC afpNoMoreLocks = -5015;
  9778.  
  9779. æKY afpNoServer
  9780. æFp Errors.p
  9781. æC afpNoServer = -5016;
  9782.  
  9783. æKY afpObjectExists
  9784. æFp Errors.p
  9785. æC afpObjectExists = -5017;
  9786.  
  9787. æKY afpObjectLocked
  9788. æFp Errors.p
  9789. æC afpObjectLocked = -5032; {Object is M/R/D/W inhibited}
  9790.  
  9791. æKY afpObjectNotFound
  9792. æFp Errors.p
  9793. æC afpObjectNotFound = -5018;
  9794.  
  9795. æKY afpObjectTypeErr
  9796. æFp Errors.p
  9797. æC afpObjectTypeErr = -5025;
  9798.  
  9799. æKY afpParmErr
  9800. æFp Errors.p
  9801. æC afpParmErr = -5019;
  9802.  
  9803. æKY afpRangeNotLocked
  9804. æFp Errors.p
  9805. æC afpRangeNotLocked = -5020;
  9806.  
  9807. æKY afpRangeOverlap
  9808. æFp Errors.p
  9809. æC afpRangeOverlap = -5021;
  9810.  
  9811. æKY afpServerGoingDown
  9812. æFp Errors.p
  9813. æC afpServerGoingDown = -5027;
  9814.  
  9815. æKY afpSessClosed
  9816. æFp Errors.p
  9817. æC afpSessClosed = -5022;
  9818.  
  9819. æKY afpTooManyFilesOpen
  9820. æFp Errors.p
  9821. æC afpTooManyFilesOpen = -5026;
  9822.  
  9823. æKY afpUserNotAuth
  9824. æFp Errors.p
  9825. æC afpUserNotAuth = -5023;
  9826.  
  9827. æKY afpVolLocked
  9828. æFp Errors.p
  9829. æC afpVolLocked = -5031; {Volume is Read-Only}
  9830.  
  9831. æKY aspBadVersNum
  9832. æFp Errors.p
  9833. æC aspBadVersNum = -1066; {Server cannot support this ASP version}
  9834.  
  9835. æKY aspBufTooSmall
  9836. æFp Errors.p
  9837. æC aspBufTooSmall = -1067; {Buffer too small}
  9838.  
  9839. æKY aspNoAck
  9840. æFp Errors.p
  9841. æC aspNoAck = -1075; {No ack on attention request (server err)}
  9842.  
  9843. æKY aspNoMoreSess
  9844. æFp Errors.p
  9845. æC aspNoMoreSess = -1068; {No more sessions on server}
  9846.  
  9847. æKY aspNoServers
  9848. æFp Errors.p
  9849. æC aspNoServers = -1069; {No servers at that address}
  9850.  
  9851. æKY aspParamErr
  9852. æFp Errors.p
  9853. æC aspParamErr = -1070; {Parameter error}
  9854.  
  9855. æKY aspServerBusy
  9856. æFp Errors.p
  9857. æC aspServerBusy = -1071; {Server cannot open another session}
  9858.  
  9859. æKY aspSessClosed
  9860. æFp Errors.p
  9861. æC aspSessClosed = -1072; {Session closed}
  9862.  
  9863. æKY aspSizeErr
  9864. æFp Errors.p
  9865. æC aspSizeErr = -1073; {Command block too big}
  9866.  
  9867. æKY aspTooMany
  9868. æFp Errors.p
  9869. æC aspTooMany = -1074; {Too many clients (server error)}
  9870.  
  9871. æKY atpBadRsp
  9872. æFp Errors.p
  9873. æC atpBadRsp = -3107;
  9874.  
  9875. æKY atpLenErr
  9876. æFp Errors.p
  9877. æC atpLenErr = -3106;
  9878.  
  9879. æKY badATPSkt
  9880. æFp Errors.p
  9881. æC badATPSkt = -1099;
  9882.  
  9883. æKY badBtSlpErr
  9884. æFp Errors.p
  9885. æC badBtSlpErr = -70; {bad addr mark bit slip nibbles}
  9886.  
  9887. æKY badBuffNum
  9888. æFp Errors.p
  9889. æC badBuffNum = -1100;
  9890.  
  9891. æKY badChannel
  9892. æFp Errors.p
  9893. æC badChannel = -205; {Sound Manager Error Returns}
  9894.  
  9895. æKY badCksmErr
  9896. æFp Errors.p
  9897. æC badCksmErr = -69; {addr mark checksum didn't check}
  9898.  
  9899. æKY badDBtSlp
  9900. æFp Errors.p
  9901. æC badDBtSlp = -73; {bad data mark bit slip nibbles}
  9902.  
  9903. æKY badDCksum
  9904. æFp Errors.p
  9905. æC badDCksum = -72; {bad data mark checksum}
  9906.  
  9907. æKY badFormat
  9908. æFp Errors.p
  9909. æC badFormat = -206; {Sound Manager Error Returns}
  9910.  
  9911. æKY badMDBErr
  9912. æFp Errors.p
  9913. æC badMDBErr = -60; {bad master directory block}
  9914.  
  9915. æKY badMovErr
  9916. æFp Errors.p
  9917. æC badMovErr = -122; {Move into offspring error}
  9918.  
  9919. æKY badUnitErr
  9920. æFp Errors.p
  9921. æC badUnitErr = -21; {I/O System Errors}
  9922.  
  9923. æKY bdNamErr
  9924. æFp Errors.p
  9925. æC bdNamErr = -37; {there may be no bad names in the final system!}
  9926.  
  9927. æKY breakRecd
  9928. æFp Errors.p
  9929. æC breakRecd = -90; {Break received (SCC)}
  9930.  
  9931. æKY buf2SmallErr
  9932. æFp Errors.p
  9933. æC buf2SmallErr = -3101;
  9934.  
  9935. æKY cantStepErr
  9936. æFp Errors.p
  9937. æC cantStepErr = -75; {step handshake failed}
  9938.  
  9939. æKY cbNotFound
  9940. æFp Errors.p
  9941. æC cbNotFound = -1102;
  9942.  
  9943. æKY cDevErr
  9944. æFp Errors.p
  9945. æC cDevErr = -155; {invalid type of graphics device}
  9946.  
  9947. æKY ckSumErr
  9948. æFp Errors.p
  9949. æC ckSumErr = -3103;
  9950.  
  9951. æKY clkRdErr,clkWrErr,prInitErr,prWrErr,qErr
  9952. æFp Errors.p
  9953. æC 
  9954.   { Result codes }
  9955.  
  9956.   clkRdErr      = -85;   {unable to read clock}
  9957.   clkWrErr      = -86;   {time written did not verify}
  9958.   memFullErr    = -108;  {not enough room in heap zone}
  9959.   memWZErr      = -111;  {attempt to operate on a free block}
  9960.   nilHandleErr  = -109;  {NIL master pointer}
  9961.   noErr         = 0;     {no error}
  9962.   prInitErr     = -88;   {validity status is not $A8}
  9963.   prWrErr       = -87;   {parameter RAM written did not verify}
  9964.   qErr          = -1     {entry not in specified queue}
  9965.  
  9966. æKY closErr
  9967. æFp Errors.p
  9968. æC closErr = -24; {I/O System Errors}
  9969.  
  9970. æKY cMatchErr
  9971. æFp Errors.p
  9972. æC cMatchErr = -150; {Color2Index failed to find an index}
  9973.  
  9974. æKY cNoMemErr
  9975. æFp Errors.p
  9976. æC cNoMemErr = -152; {failed to allocate memory for structure}
  9977.  
  9978. æKY controlErr
  9979. æFp Errors.p
  9980. æC controlErr = -17; {I/O System Errors}
  9981.  
  9982. æKY corErr
  9983. æFp Errors.p
  9984. æC corErr = -3; {core routine number out of range}
  9985.  
  9986. æKY cProtectErr
  9987. æFp Errors.p
  9988. æC cProtectErr = -154; {colorTable entry protection violation}
  9989.  
  9990. æKY cRangeErr
  9991. æFp Errors.p
  9992. æC cRangeErr = -153; {range error on colorTable request}
  9993.  
  9994. æKY cResErr
  9995. æFp Errors.p
  9996. æC cResErr = -156; {invalid resolution for MakeITable}
  9997.  
  9998. æKY cTempMemErr
  9999. æFp Errors.p
  10000. æC cTempMemErr = -151; {failed to allocate memory for temporary structures}
  10001.  
  10002. æKY dataVerErr
  10003. æFp Errors.p
  10004. æC dataVerErr = -68; {read verify compare failed}
  10005.  
  10006. æKY dceExtErr
  10007. æFp Errors.p
  10008. æC dceExtErr = -30; {dce extension error}
  10009.  
  10010. æKY ddpLenErr
  10011. æFp Errors.p
  10012. æC ddpLenErr = -92; {data length too big}
  10013.  
  10014. æKY ddpSktErr
  10015. æFp Errors.p
  10016. æC ddpSktErr = -91; {error in soket number}
  10017.  
  10018. æKY dInstErr
  10019. æFp Errors.p
  10020. æC dInstErr = -26; {DrvrInstall couldn't find driver in resources }
  10021.  
  10022. æKY dirFulErr
  10023. æFp Errors.p
  10024. æC dirFulErr = -33; {Directory full}
  10025.  
  10026. æKY dirNFErr
  10027. æFp Errors.p
  10028. æC dirNFErr = -120; {Directory not found}
  10029.  
  10030. æKY dRemovErr
  10031. æFp Errors.p
  10032. æC dRemovErr = -25; {tried to remove an open driver}
  10033.  
  10034. æKY dsAddressErr
  10035. æFp Errors.p
  10036. æC dsAddressErr = 2; {address error}
  10037.  
  10038. æKY dsBadLaunch
  10039. æFp Errors.p
  10040. æC dsBadLaunch = 26; {can't launch file}
  10041.  
  10042. æKY dsBadPatch
  10043. æFp Errors.p
  10044. æC dsBadPatch = 99; {Can't load patch resource}
  10045.  
  10046. æKY dsBadSANEopcode
  10047. æFp Errors.p
  10048. æC dsBadSANEopcode = 81; {bad opcode given to SANE Pack4}
  10049.  
  10050. æKY dsBadSlotInt
  10051. æFp Errors.p
  10052. æC dsBadSlotInt = 51; {unserviceable slot interrupt}
  10053.  
  10054. æKY dsBusError
  10055. æFp Errors.p
  10056. æC dsBusError = 1; {bus error }
  10057.  
  10058. æKY dsChkErr
  10059. æFp Errors.p
  10060. æC dsChkErr = 5; {check trap error}
  10061.  
  10062. æKY dsCoreErr
  10063. æFp Errors.p
  10064. æC dsCoreErr = 12; {unimplemented core routine error}
  10065.  
  10066. æKY dsFinderErr
  10067. æFp Errors.p
  10068. æC dsFinderErr = 41; {can't load the Finder error}
  10069.  
  10070. æKY dsFPErr
  10071. æFp Errors.p
  10072. æC dsFPErr = 16; {Floating point error}
  10073.  
  10074. æKY dsFSErr
  10075. æFp Errors.p
  10076. æC dsFSErr = 27; {file system map has been trashed}
  10077.  
  10078. æKY dsGreeting
  10079. æFp Errors.p
  10080. æC dsGreeting = 40; {welcome to Macintosh greeting}
  10081.  
  10082. æKY dsHMenuFindErr
  10083. æFp Errors.p
  10084. æC dsHMenuFindErr = 86; {Menu Manager Errors}
  10085.  
  10086. æKY dsIllInstErr
  10087. æFp Errors.p
  10088. æC dsIllInstErr = 3; {illegal instruction error}
  10089.  
  10090. æKY dsIOCoreErr
  10091. æFp Errors.p
  10092. æC dsIOCoreErr = 14; {IO Core Error}
  10093.  
  10094. æKY dsIrqErr
  10095. æFp Errors.p
  10096. æC dsIrqErr = 13; {uninstalled interrupt error}
  10097.  
  10098. æKY dskFulErr
  10099. æFp Errors.p
  10100. æC dskFulErr = -34; {disk full}
  10101.  
  10102. æKY dsLineAErr
  10103. æFp Errors.p
  10104. æC dsLineAErr = 9; {line 1010 trap error}
  10105.  
  10106. æKY dsLineFErr
  10107. æFp Errors.p
  10108. æC dsLineFErr = 10; {line 1111 trap error}
  10109.  
  10110. æKY dsLoadErr
  10111. æFp Errors.p
  10112. æC dsLoadErr = 15; {Segment Loader Error}
  10113.  
  10114. æKY dsMBarNFnd
  10115. æFp Errors.p
  10116. æC dsMBarNFnd = 85; {Menu Manager Errors}
  10117.  
  10118. æKY dsMemFullErr
  10119. æFp Errors.p
  10120. æC dsMemFullErr = 25; {out of memory!}
  10121.  
  10122. æKY dsMiscErr
  10123. æFp Errors.p
  10124. æC dsMiscErr = 11; {miscellaneous hardware exception error}
  10125.  
  10126. æKY dsNoPackErr
  10127. æFp Errors.p
  10128. æC dsNoPackErr = 17; {package 0 not present}
  10129.  
  10130. æKY dsNoPatch
  10131. æFp Errors.p
  10132. æC dsNoPatch = 98; {Can't patch for particular Model Mac}
  10133.  
  10134. æKY dsNoPk1
  10135. æFp Errors.p
  10136. æC dsNoPk1 = 18; {package 1 not present}
  10137.  
  10138. æKY dsNoPk2
  10139. æFp Errors.p
  10140. æC dsNoPk2 = 19; {package 2 not present}
  10141.  
  10142. æKY dsNoPk3
  10143. æFp Errors.p
  10144. æC dsNoPk3 = 20; {package 3 not present}
  10145.  
  10146. æKY dsNoPk4
  10147. æFp Errors.p
  10148. æC dsNoPk4 = 21; {package 4 not present}
  10149.  
  10150. æKY dsNoPk5
  10151. æFp Errors.p
  10152. æC dsNoPk5 = 22; {package 5 not present}
  10153.  
  10154. æKY dsNoPk6
  10155. æFp Errors.p
  10156. æC dsNoPk6 = 23; {package 6 not present}
  10157.  
  10158. æKY dsNoPk7
  10159. æFp Errors.p
  10160. æC dsNoPk7 = 24; {package 7 not present}
  10161.  
  10162. æKY dsNotThe1
  10163. æFp Errors.p
  10164. æC dsNotThe1 = 31; {not the disk I wanted}
  10165.  
  10166. æKY dsOvflowErr
  10167. æFp Errors.p
  10168. æC dsOvflowErr = 6; {overflow trap error}
  10169.  
  10170. æKY dsPrivErr
  10171. æFp Errors.p
  10172. æC dsPrivErr = 7; {privilege violation error}
  10173.  
  10174. æKY dsReinsert
  10175. æFp Errors.p
  10176. æC dsReinsert = 30; {request user to reinsert off-line volume}
  10177.  
  10178. æKY dsStknHeap
  10179. æFp Errors.p
  10180. æC dsStknHeap = 28; {stack has moved into application heap}
  10181.  
  10182. æKY dsSysErr
  10183. æFp Errors.p
  10184. æC dsSysErr = 32767; {general system error}
  10185.  
  10186. æKY dsTraceErr
  10187. æFp Errors.p
  10188. æC dsTraceErr = 8; {trace mode error}
  10189.  
  10190. æKY dsZeroDivErr
  10191. æFp Errors.p
  10192. æC dsZeroDivErr = 4; {zero divide error}
  10193.  
  10194. æKY dupFNErr
  10195. æFp Errors.p
  10196. æC dupFNErr = -48; {duplicate filename (rename)}
  10197.  
  10198. æKY envBadVers
  10199. æFp Errors.p
  10200. æC envBadVers = -5501; {Version non-positive}
  10201.  
  10202. æKY envNotPresent
  10203. æFp Errors.p
  10204. æC envNotPresent = -5500; {returned by glue.}
  10205.  
  10206. æKY envVersTooBig
  10207. æFp Errors.p
  10208. æC envVersTooBig = -5502; {Version bigger than call can handle}
  10209.  
  10210. æKY eofErr
  10211. æFp Errors.p
  10212. æC eofErr = -39; {End of file}
  10213.  
  10214. æKY evtNotEnb
  10215. æFp Errors.p
  10216. æC evtNotEnb = 1; {event not enabled at PostEvent}
  10217.  
  10218. æKY excessCollsns
  10219. æFp Errors.p
  10220. æC excessCollsns = -95; {excessive collisions on write}
  10221.  
  10222. æKY extFSErr
  10223. æFp Errors.p
  10224. æC extFSErr = -58; {volume in question belongs to an external fs}
  10225.  
  10226. æKY extractErr
  10227. æFp Errors.p
  10228. æC extractErr = -3104;
  10229.  
  10230. æKY exUserBreak
  10231. æFp Errors.p
  10232. æC exUserBreak = -492; {user debugger break; execute debugger commands on stack}
  10233.  
  10234. æKY fBsyErr
  10235. æFp Errors.p
  10236. æC fBsyErr = -47; {File is busy (delete)}
  10237.  
  10238. æKY firstDskErr
  10239. æFp Errors.p
  10240. æC firstDskErr = -84; {I/O System Errors}
  10241.  
  10242. æKY fLckdErr
  10243. æFp Errors.p
  10244. æC fLckdErr = -45; {file is locked}
  10245.  
  10246. æKY fmt1Err
  10247. æFp Errors.p
  10248. æC fmt1Err = -82; {can't find sector 0 after track format}
  10249.  
  10250. æKY fmt2Err
  10251. æFp Errors.p
  10252. æC fmt2Err = -83; {can't get enough sync}
  10253.  
  10254. æKY fnfErr
  10255. æFp Errors.p
  10256. æC fnfErr = -43; {File not found}
  10257.  
  10258. æKY fnOpnErr
  10259. æFp Errors.p
  10260. æC fnOpnErr = -38; {File not open}
  10261.  
  10262. æKY fontDecError
  10263. æFp Errors.p
  10264. æC fontDecError = -64; {error during font declaration}
  10265.  
  10266. æKY fontNotDeclared
  10267. æFp Errors.p
  10268. æC fontNotDeclared = -65; {font not declared}
  10269.  
  10270. æKY fontSubErr
  10271. æFp Errors.p
  10272. æC fontSubErr = -66; {font substitution occured}
  10273.  
  10274. æKY framingErr
  10275. æFp Errors.p
  10276. æC framingErr = 64; {serial driver error masks}
  10277.  
  10278. æKY fsDSIntErr
  10279. æFp Errors.p
  10280. æC fsDSIntErr = -127; {Internal file system error}
  10281.  
  10282. æKY fsRnErr
  10283. æFp Errors.p
  10284. æC fsRnErr = -59; {file system internal error:during rename the old entry was deleted but 
  10285.                 could not be restored.}
  10286.  
  10287. æKY gcrOnMFMErr
  10288. æFp Errors.p
  10289. æC gcrOnMFMErr = -400; {gcr format on high density media error}
  10290.  
  10291. æKY gfpErr
  10292. æFp Errors.p
  10293. æC gfpErr = -52; {get file position error}
  10294.  
  10295. æKY hMenuFindErr
  10296. æFp Errors.p
  10297. æC hMenuFindErr = -127; {could not find HMenu's parent in MenuKey}
  10298.  
  10299. æKY hwOverrunErr
  10300. æFp Errors.p
  10301. æC hwOverrunErr = 32; {serial driver error masks}
  10302.  
  10303. æKY hwParamErr
  10304. æFp Errors.p
  10305. æC hwParamErr = -502; {bad selector for _HWPriv}
  10306.  
  10307. æKY iIOAbortErr
  10308. æFp Errors.p
  10309. æC iIOAbortErr = -27; {IO abort error (Printing Manager)}
  10310.  
  10311. æKY initIWMErr
  10312. æFp Errors.p
  10313. æC initIWMErr = -77; {unable to initialize IWM}
  10314.  
  10315. æKY ioErr
  10316. æFp Errors.p
  10317. æC ioErr = -36; {I/O error (bummers)}
  10318.  
  10319. æKY lapProtErr
  10320. æFp Errors.p
  10321. æC lapProtErr = -94; {error in attaching/detaching protocol}
  10322.  
  10323. æKY lastDskErr
  10324. æFp Errors.p
  10325. æC lastDskErr = -64; {I/O System Errors}
  10326.  
  10327. æKY mapReadErr
  10328. æFp Errors.p
  10329. æC mapReadErr = -199; {map inconsistent with operation}
  10330.  
  10331. æKY mBarNFnd
  10332. æFp Errors.p
  10333. æC mBarNFnd = -126; {system error code for MBDF not found}
  10334.  
  10335. æKY memAdrErr
  10336. æFp Errors.p
  10337. æC memAdrErr = -110; {address was odd; or out of range}
  10338.  
  10339. æKY memAZErr
  10340. æFp Errors.p
  10341. æC memAZErr = -113; {Address in zone check failed}
  10342.  
  10343. æKY memBCErr
  10344. æFp Errors.p
  10345. æC memBCErr = -115; {Block Check failed}
  10346.  
  10347. æKY memPCErr
  10348. æFp Errors.p
  10349. æC memPCErr = -114; {Pointer Check failed}
  10350.  
  10351. æKY memROZErr,memFullErr,memLockedErr,memPurErr,memWZErr,nilHandleErr,noErr
  10352. æFp Errors.p
  10353. æC 
  10354.   { Result codes for Memory Manager }
  10355.  
  10356.   memROZErr     =  -99;    {operation on a read-only zone}
  10357.   memFullErr    = -108;    {not enough room in heap zone}
  10358.   memLockedErr  = -117;    {block is locked}
  10359.   memPurErr     = -112;    {attempt to purge a locked block}
  10360.   memWZErr      = -111;    {attempt to operate on a free block}
  10361.   nilHandleErr  = -109;    {NIL master pointer}
  10362.   noErr         =    0;    {no error}
  10363.  
  10364. æKY memROZWarn
  10365. æFp Errors.p
  10366. æC memROZWarn = -99; {soft error in ROZ}
  10367.  
  10368. æKY memSCErr
  10369. æFp Errors.p
  10370. æC memSCErr = -116; {Size Check failed}
  10371.  
  10372. æKY menuPrgErr
  10373. æFp Errors.p
  10374. æC menuPrgErr = 84; {happens when a menu is purged}
  10375.  
  10376. æKY mFulErr
  10377. æFp Errors.p
  10378. æC mFulErr = -41; {memory full (open) or file won't fit (load)}
  10379.  
  10380. æKY nbpBuffOvr
  10381. æFp Errors.p
  10382. æC nbpBuffOvr = -1024; {Buffer overflow in LookupName}
  10383.  
  10384. æKY nbpConfDiff
  10385. æFp Errors.p
  10386. æC nbpConfDiff = -1026; {Name confirmed at different socket}
  10387.  
  10388. æKY nbpDuplicate
  10389. æFp Errors.p
  10390. æC nbpDuplicate = -1027; {Duplicate name exists already}
  10391.  
  10392. æKY nbpNISErr
  10393. æFp Errors.p
  10394. æC nbpNISErr = -1029; {Error trying to open the NIS}
  10395.  
  10396. æKY nbpNoConfirm
  10397. æFp Errors.p
  10398. æC nbpNoConfirm = -1025;
  10399.  
  10400. æKY nbpNotFound
  10401. æFp Errors.p
  10402. æC nbpNotFound = -1028; {Name not found on remove}
  10403.  
  10404. æKY negZcbFreeErr
  10405. æFp Errors.p
  10406. æC negZcbFreeErr = 33; {ZcbFree has gone negative}
  10407.  
  10408. æKY nmTypErr
  10409. æFp Errors.p
  10410. æC nmTypErr = -299;
  10411.  
  10412. æKY noAdrMkErr
  10413. æFp Errors.p
  10414. æC noAdrMkErr = -67; {couldn't find valid addr mark}
  10415.  
  10416. æKY noBridgeErr
  10417. æFp Errors.p
  10418. æC noBridgeErr = -93; {no network bridge for non-local send}
  10419.  
  10420. æKY noDataArea
  10421. æFp Errors.p
  10422. æC noDataArea = -1104;
  10423.  
  10424. æKY noDriveErr
  10425. æFp Errors.p
  10426. æC noDriveErr = -64; {drive not installed}
  10427.  
  10428. æKY noDtaMkErr
  10429. æFp Errors.p
  10430. æC noDtaMkErr = -71; {couldn't find a data mark header}
  10431.  
  10432. æKY noHardware
  10433. æFp Errors.p
  10434. æC noHardware = -200; {Sound Manager Error Returns}
  10435.  
  10436. æKY noMacDskErr
  10437. æFp Errors.p
  10438. æC noMacDskErr = -57; {not a mac diskette (sig bytes are wrong)}
  10439.  
  10440. æKY noMPPErr
  10441. æFp Errors.p
  10442. æC noMPPErr = -3102;
  10443.  
  10444. æKY noNybErr
  10445. æFp Errors.p
  10446. æC noNybErr = -66; {couldn't find 5 nybbles in 200 tries}
  10447.  
  10448. æKY noRelErr
  10449. æFp Errors.p
  10450. æC noRelErr = -1101;
  10451.  
  10452. æKY noScrapErr,noTypeErr
  10453. æFp Errors.p
  10454. æC 
  10455.   { Scrap Manager result codes }
  10456.  
  10457.   noScrapErr = -100;   {desk scrap isn't initialized}
  10458.   noTypeErr  = -102;    {no data of the requested type}
  10459.  
  10460. æKY noSendResp
  10461. æFp Errors.p
  10462. æC noSendResp = -1103;
  10463.  
  10464. æKY notEnoughHardware
  10465. æFp Errors.p
  10466. æC notEnoughHardware = -201; {Sound Manager Error Returns}
  10467.  
  10468. æKY notOpenErr
  10469. æFp Errors.p
  10470. æC notOpenErr = -28; {Couldn't rd/wr/ctl/sts cause driver not opened}
  10471.  
  10472. æKY nsDrvErr
  10473. æFp Errors.p
  10474. æC nsDrvErr = -56; {no such drive (tried to mount a bad drive num)}
  10475.  
  10476. æKY nsvErr
  10477. æFp Errors.p
  10478. æC nsvErr = -35; {no such volume}
  10479.  
  10480. æKY offLinErr
  10481. æFp Errors.p
  10482. æC offLinErr = -65; {r/w requested for an off-line drive}
  10483.  
  10484. æKY openErr
  10485. æFp Errors.p
  10486. æC openErr = -23; {I/O System Errors}
  10487.  
  10488. æKY opWrErr
  10489. æFp Errors.p
  10490. æC opWrErr = -49; {file already open with with write permission}
  10491.  
  10492. æKY paramErr
  10493. æFp Errors.p
  10494. æC paramErr = -50; {error in user parameter list}
  10495.  
  10496. æKY parityErr
  10497. æFp Errors.p
  10498. æC parityErr = 16; {serial driver error masks}
  10499.  
  10500. æKY permErr
  10501. æFp Errors.p
  10502. æC permErr = -54; {permissions error (on file open)}
  10503.  
  10504. æKY portInUse
  10505. æFp Errors.p
  10506. æC portInUse = -97; {driver Open error code (port is in use)}
  10507.  
  10508. æKY portNotCf
  10509. æFp Errors.p
  10510. æC portNotCf = -98; {driver Open error code (parameter RAM not configured for this 
  10511.                   connection)}
  10512.  
  10513. æKY posErr
  10514. æFp Errors.p
  10515. æC posErr = -40; {tried to position to before start of file (r/w)}
  10516.  
  10517. æKY queueFull
  10518. æFp Errors.p
  10519. æC queueFull = -203; {Sound Manager Error Returns}
  10520.  
  10521. æKY rcvrErr
  10522. æFp Errors.p
  10523. æC rcvrErr = -89; {SCC receiver error (framing; parity; OR)}
  10524.  
  10525. æKY readErr
  10526. æFp Errors.p
  10527. æC readErr = -19; {I/O System Errors}
  10528.  
  10529. æKY readQErr
  10530. æFp Errors.p
  10531. æC readQErr = -3105;
  10532.  
  10533. æKY recNotFnd
  10534. æFp Errors.p
  10535. æC recNotFnd = -3108;
  10536.  
  10537. æKY reqAborted
  10538. æFp Errors.p
  10539. æC reqAborted = -1105;
  10540.  
  10541. æKY reqFailed
  10542. æFp Errors.p
  10543. æC reqFailed = -1096;
  10544.  
  10545. æKY resAttrErr
  10546. æFp Errors.p
  10547. æC resAttrErr = -198; {attribute inconsistent with operation}
  10548.  
  10549. æKY resFNotFound
  10550. æFp Errors.p
  10551. æC resFNotFound = -193; {Resource file not found}
  10552.  
  10553. æKY resNotFound
  10554. æFp Errors.p
  10555. æC resNotFound = -192; {Resource not found}
  10556.  
  10557. æKY resProblem
  10558. æFp Errors.p
  10559. æC resProblem = -204; {Sound Manager Error Returns}
  10560.  
  10561. æKY rfNumErr
  10562. æFp Errors.p
  10563. æC rfNumErr = -51; {refnum error}
  10564.  
  10565. æKY rgnTooBigErr
  10566. æFp Errors.p
  10567. æC rgnTooBigErr = -500;
  10568.  
  10569. æKY rmvRefFailed
  10570. æFp Errors.p
  10571. æC rmvRefFailed = -197; {RmveReference failed}
  10572.  
  10573. æKY rmvResFailed
  10574. æFp Errors.p
  10575. æC rmvResFailed = -196; {RmveResource failed}
  10576.  
  10577. æKY sdmInitErr
  10578. æFp Errors.p
  10579. æC sdmInitErr = 11; {SDM could not be initialized.}
  10580.  
  10581. æKY sdmJTInitErr
  10582. æFp Errors.p
  10583. æC sdmJTInitErr = 10; {SDM Jump Table could not be initialized.}
  10584.  
  10585. æKY sdmPRAMInitErr
  10586. æFp Errors.p
  10587. æC sdmPRAMInitErr = 13; {Slot PRAM could not be initialized.}
  10588.  
  10589. æKY sdmPriInitErr
  10590. æFp Errors.p
  10591. æC sdmPriInitErr = 14; {Cards could not be initialized.}
  10592.  
  10593. æKY sdmSRTInitErr
  10594. æFp Errors.p
  10595. æC sdmSRTInitErr = 12; {Slot Resource Table could not be initialized.}
  10596.  
  10597. æKY sectNFErr
  10598. æFp Errors.p
  10599. æC sectNFErr = -81; {sector number never found on a track}
  10600.  
  10601. æKY seekErr
  10602. æFp Errors.p
  10603. æC seekErr = -80; {track number wrong on address mark}
  10604.  
  10605. æKY seNoDB
  10606. æFp Errors.p
  10607. æC seNoDB = -8; {no debugger installed to handle debugger command}
  10608.  
  10609. æKY shutDownAlert
  10610. æFp Errors.p
  10611. æC shutDownAlert = 42; {handled like a shutdown error}
  10612.  
  10613. æKY siInitSDTblErr
  10614. æFp Errors.p
  10615. æC siInitSDTblErr = 1; {slot int dispatch table could not be initialized.}
  10616.  
  10617. æKY siInitSPTblErr
  10618. æFp Errors.p
  10619. æC siInitSPTblErr = 3; {slot priority table could not be initialized.}
  10620.  
  10621. æKY siInitVBLQsErr
  10622. æFp Errors.p
  10623. æC siInitVBLQsErr = 2; {VBLqueues for all slots could not be initialized.}
  10624.  
  10625. æKY sktClosedErr
  10626. æFp Errors.p
  10627. æC sktClosedErr = -3109;
  10628.  
  10629. æKY slotNumErr
  10630. æFp Errors.p
  10631. æC slotNumErr = -360; {invalid slot # error}
  10632.  
  10633. æKY smBadBoardId
  10634. æFp Errors.p
  10635. æC smBadBoardId = -319; {BoardId was wrong; re-init the PRAM record.}
  10636.  
  10637. æKY smBadRefId
  10638. æFp Errors.p
  10639. æC smBadRefId = -330; {Reference Id not found in List}
  10640.  
  10641. æKY smBadsList
  10642. æFp Errors.p
  10643. æC smBadsList = -331; {Bad sList: Id1 < Id2 < Id3 ...format is not followed.}
  10644.  
  10645. æKY smBadsPtrErr
  10646. æFp Errors.p
  10647. æC smBadsPtrErr = -346; {Bad pointer was passed to sCalcsPointer}
  10648.  
  10649. æKY smBLFieldBad
  10650. æFp Errors.p
  10651. æC smBLFieldBad = -309; {ByteLanes field was bad.}
  10652.  
  10653. æKY smBlkMoveErr
  10654. æFp Errors.p
  10655. æC smBlkMoveErr = -340; {_BlockMove error}
  10656.  
  10657. æKY smBusErrTO
  10658. æFp Errors.p
  10659. æC smBusErrTO = -320; {BusError time out.}
  10660.  
  10661. æKY smByteLanesErr
  10662. æFp Errors.p
  10663. æC smByteLanesErr = -347; {NumByteLanes was determined to be zero.}
  10664.  
  10665. æKY smCkStatusErr
  10666. æFp Errors.p
  10667. æC smCkStatusErr = -341; {Status of slot = fail.}
  10668.  
  10669. æKY smCodeRevErr
  10670. æFp Errors.p
  10671. æC smCodeRevErr = -333; {Code revision is wrong}
  10672.  
  10673. æKY smCPUErr
  10674. æFp Errors.p
  10675. æC smCPUErr = -334; {Code revision is wrong}
  10676.  
  10677. æKY smCRCFail
  10678. æFp Errors.p
  10679. æC smCRCFail = -301; {CRC check failed for declaration data}
  10680.  
  10681. æKY smDisDrvrNamErr
  10682. æFp Errors.p
  10683. æC smDisDrvrNamErr = -343; {Error occured during _sDisDrvrName.}
  10684.  
  10685. æKY smDisposePErr
  10686. æFp Errors.p
  10687. æC smDisposePErr = -312; {_DisposePointer error}
  10688.  
  10689. æKY smEmptySlot
  10690. æFp Errors.p
  10691. æC smEmptySlot = -300; {No card in slot}
  10692.  
  10693. æKY smFHBlockRdErr
  10694. æFp Errors.p
  10695. æC smFHBlockRdErr = -310; {Error occured during _sGetFHeader.}
  10696.  
  10697. æKY smFormatErr
  10698. æFp Errors.p
  10699. æC smFormatErr = -302; {FHeader Format is not Apple's}
  10700.  
  10701. æKY smGetDrvrNamErr
  10702. æFp Errors.p
  10703. æC smGetDrvrNamErr = -342; {Error occured during _sGetDrvrName.}
  10704.  
  10705. æKY smGetPRErr
  10706. æFp Errors.p
  10707. æC smGetPRErr = -314; {Error occured during _sGetPRAMRec (See SIMStatus).}
  10708.  
  10709. æKY smInitStatVErr
  10710. æFp Errors.p
  10711. æC smInitStatVErr = -316; {The InitStatusV field was negative after primary or secondary 
  10712.                          init.}
  10713.  
  10714. æKY smInitTblErr
  10715. æFp Errors.p
  10716. æC smInitTblErr = -317; {An error occured while trying to initialize the Slot Resource 
  10717.                       Table.}
  10718.  
  10719. æKY smLWTstBad
  10720. æFp Errors.p
  10721. æC smLWTstBad = -305; {Long Word test field <> $5A932BC7.}
  10722.  
  10723. æKY smNewPErr
  10724. æFp Errors.p
  10725. æC smNewPErr = -339; {_NewPtr error}
  10726.  
  10727. æKY smNilsBlockErr
  10728. æFp Errors.p
  10729. æC smNilsBlockErr = -336; {Nil sBlock error (Dont allocate and try to use a nil sBlock)}
  10730.  
  10731. æKY smNoBoardId
  10732. æFp Errors.p
  10733. æC smNoBoardId = -315; {No Board Id.}
  10734.  
  10735. æKY smNoBoardsRsrc
  10736. æFp Errors.p
  10737. æC smNoBoardsRsrc = -313; {No Board sResource.}
  10738.  
  10739. æKY smNoDir
  10740. æFp Errors.p
  10741. æC smNoDir = -304; {Directory offset is Nil }
  10742.  
  10743. æKY smNoGoodOpens
  10744. æFp Errors.p
  10745. æC smNoGoodOpens = -349; {No opens were successfull in the loop.}
  10746.  
  10747. æKY smNoJmpTbl
  10748. æFp Errors.p
  10749. æC smNoJmpTbl = -318; {SDM jump table could not be created.}
  10750.  
  10751. æKY smNoMoresRsrcs
  10752. æFp Errors.p
  10753. æC smNoMoresRsrcs = -344; {No more sResources}
  10754.  
  10755. æKY smNosInfoArray
  10756. æFp Errors.p
  10757. æC smNosInfoArray = -306; {No sInfoArray. Memory Mgr error.}
  10758.  
  10759. æKY smOffsetErr
  10760. æFp Errors.p
  10761. æC smOffsetErr = -348; {Offset was too big (temporary error}
  10762.  
  10763. æKY smPRAMInitErr
  10764. æFp Errors.p
  10765. æC smPRAMInitErr = -292; {Error; Slot Resource Table could not be initialized.}
  10766.  
  10767. æKY smPriInitErr
  10768. æFp Errors.p
  10769. æC smPriInitErr = -293; {Error; Cards could not be initialized.}
  10770.  
  10771. æKY smRecNotFnd
  10772. æFp Errors.p
  10773. æC smRecNotFnd = -351; {Record not found in the SRT.}
  10774.  
  10775. æKY smReservedErr
  10776. æFp Errors.p
  10777. æC smReservedErr = -332; {Reserved field not zero}
  10778.  
  10779. æKY smResrvErr
  10780. æFp Errors.p
  10781. æC smResrvErr = -307; {Fatal reserved error. Resreved field <> 0.}
  10782.  
  10783. æKY smRevisionErr
  10784. æFp Errors.p
  10785. æC smRevisionErr = -303; {Wrong revison level}
  10786.  
  10787. æKY smSDMInitErr
  10788. æFp Errors.p
  10789. æC smSDMInitErr = -290; {Error; SDM could not be initialized.}
  10790.  
  10791. æKY smSelOOBErr
  10792. æFp Errors.p
  10793. æC smSelOOBErr = -338; {Selector out of bounds error}
  10794.  
  10795. æKY smsGetDrvrErr
  10796. æFp Errors.p
  10797. æC smsGetDrvrErr = -345; {Error occurred during _sGetDriver.}
  10798.  
  10799. æKY smSlotOOBErr
  10800. æFp Errors.p
  10801. æC smSlotOOBErr = -337; {Slot out of bounds error}
  10802.  
  10803. æKY smsPointerNil
  10804. æFp Errors.p
  10805. æC smsPointerNil = -335; {LPointer is nil From sOffsetData. If this error occurs; check 
  10806.                        sInfo rec for more information.}
  10807.  
  10808. æKY smSRTInitErr
  10809. æFp Errors.p
  10810. æC smSRTInitErr = -291; {Error; Slot Resource Table could not be initialized.}
  10811.  
  10812. æKY smSRTOvrFlErr
  10813. æFp Errors.p
  10814. æC smSRTOvrFlErr = -350; {SRT over flow.}
  10815.  
  10816. æKY smUnExBusErr
  10817. æFp Errors.p
  10818. æC smUnExBusErr = -308; {Unexpected BusError}
  10819.  
  10820. æKY spdAdjErr
  10821. æFp Errors.p
  10822. æC spdAdjErr = -79; {unable to correctly adjust disk speed}
  10823.  
  10824. æKY statusErr
  10825. æFp Errors.p
  10826. æC statusErr = -18; {I/O System Errors}
  10827.  
  10828. æKY strUserBreak
  10829. æFp Errors.p
  10830. æC strUserBreak = -491; {user debugger break; display string on stack}
  10831.  
  10832. æKY svDisabled
  10833. æFp Errors.p
  10834. æC svDisabled = -32640; {Reserve range -32640 to -32768 for Apple temp disables.}
  10835.  
  10836. æKY svTempDisable
  10837. æFp Errors.p
  10838. æC svTempDisable = -32768; {Temporarily disable card but run primary init.}
  10839.  
  10840. æKY swOverrunErr
  10841. æFp Errors.p
  10842. æC swOverrunErr = 1; {serial driver error masks}
  10843.  
  10844. æKY SysError
  10845. æFp Errors.p
  10846. æT PROCEDURE
  10847. æTN $A9C9
  10848. æD PROCEDURE SysError(errorCode: INTEGER);
  10849. æDT SysError(errorCode);
  10850. æMM   
  10851. æRI SysError procedure II-362, V-572
  10852. æC _____________________________________________________________________________________
  10853.  
  10854. Trap macro  _SysError
  10855. On entry    D0:  errorCode (word)
  10856. On exit     All registers changed
  10857. _____________________________________________________________________________________
  10858. SysError generates a system error with the ID specified by the errorCode 
  10859. parameter.
  10860.  
  10861. It takes the following precise steps:
  10862. 1.  It saves all registers and the stack pointer.
  10863. 2.  It stores the system error ID in a global variable (named DSErrCode).
  10864. 3.  It checks to see whether there's a system error alert table in memory (by 
  10865.     testing whether the global variable DSAlertTab is 0); if there isn't, it draws 
  10866.     the "sad Macintosh" icon.
  10867. 4.  It allocates memory for QuickDraw globals on the stack, initializes 
  10868.     QuickDraw, and initializes a grafPort in which the alert box will be drawn.
  10869. 5.  It checks the system error ID.  If the system error ID is negative, the alert 
  10870.     box isn't redrawn (this is used for system startup alerts, which can display a 
  10871.     sequence of consecutive messages in the same box).  If the system error ID 
  10872.     doesn't correspond to an entry in the system error alert table, the default 
  10873.     alert definition at the start of the table will be used, displaying the message 
  10874.     "Sorry, a system error occurred".
  10875. 6.  It draws an alert box (in the rectangle specified by the global variable 
  10876.     DSAlertRect).
  10877. 7.  If the text definition IDs in the alert definition for this alert aren't 0, it 
  10878.     draws both strings.
  10879. 8.  If the icon definition ID in the alert definition isn't 0, it draws the icon.
  10880. 9.  If the procedure definition ID in the alert definition isn't 0, it invokes the 
  10881.     procedure with the specified ID.
  10882. 10. If the button definition ID in the alert definition is 0, it returns control to 
  10883.     the procedure that called it (this is used during the disk-switch alert to return
  10884.     control to the File Manager after the "Please insert the disk:" message has been 
  10885.     displayed).
  10886. 11. If there's a resume procedure, it increments the button definition ID by 1.
  10887. 12. It draws the buttons.
  10888. 13. It hit-tests the buttons and calls the corresponding procedure code when a 
  10889.     button is pressed.  If there's no procedure code, it returns to the procedure 
  10890.     that called it.
  10891.  
  10892. User Alerts
  10893. _____________
  10894. ID  Explanation
  10895. 1   Bus error:  Invalid memory reference; happens only on a Macintosh XL 
  10896. 2   Address error:  Word or long-word reference made to an odd address
  10897. 3   Illegal instruction:  The MC68000 received an instruction it didn't recognize.
  10898. 4   Zero divide:  Signed Divide (DIVS) or Unsigned Divide (DIVU) instruction 
  10899.                   with a divisor of 0 was executed.
  10900. 5   Check exception:  Check Register Against Bounds (CHK) instruction was executed 
  10901.                       and failed.  Pascal "value out of range" errors are usually 
  10902.                       reported in this way.
  10903. 6   TrapV exception:  Trap On Overflow (TRAPV) instruction was executed and failed.
  10904. 7   Privilege violation:  Macintosh always runs in supervisor mode; perhaps an 
  10905.                           erroneous Return From Execution (RTE) instruction was 
  10906.                           executed.
  10907. 8   Trace exception:  The trace bit in the status register is set.
  10908. 9   Line 1010 exception:  The 1010 trap dispatcher has failed.
  10909. 10  Line 1111 exception:  Unimplemented instruction
  10910. 11  Miscellaneous exception:  All other MC68000 exceptions
  10911. 12  Unimplemented core routine:  An unimplemented trap number was encountered.
  10912. 13  Spurious interrupt:  The interrupt vector table entry for a particular level 
  10913.                          of interrupt is NIL; usually occurs with level 4, 5, 6, or 7 
  10914.                          interrupts.
  10915. 14  I/O system error:  The File Manager is attempting to dequeue an entry from 
  10916.                        an I/O request queue that has a bad queue type field; perhaps 
  10917.                        the queue entry is unlocked.  Or, the dCtlQHead field was NIL 
  10918.                        during a Fetch or Stash call.  Or, a needed device control 
  10919.                        entry has been purged.
  10920. 15  Segment Loader error:  A GetResource call to read a segment into memory failed.
  10921. 16  Floating point error:  The halt bit in the floating-point environment word was 
  10922.                            set.
  10923. 17-24 Can't load package:  A GetResource call to read a package into memory failed.
  10924. 25  Can't allocate requested memory block in the heap
  10925. 26  Segment Loader error:  A GetResource call to read 'CODE' resource 0 into 
  10926.                            memory failed; usually indicates a nonexecutable file.
  10927. 27  File map destroyed:  A logical block number was found that's greater than 
  10928.                          the number of the last logical block on the volume or less 
  10929.                          than the logical block number of the first allocation block 
  10930.                          on the volume.
  10931. 28  Stack overflow error:  The stack has expanded into the heap.
  10932. 30  "Please insert the disk:" File Manager alert
  10933. 41  The file named "Finder" can't be found on the disk.
  10934. 100 Can't mount system startup volume.  The system couldn't read the system resource 
  10935.                                         file into memory.
  10936. 32767 "Sorry, a system error occurred":  Default alert message 
  10937.  
  10938. æKY teScrapSizeErr
  10939. æFp Errors.p
  10940. æC teScrapSizeErr = -501; {scrap item too big for text edit record}
  10941.  
  10942. æKY tk0BadErr
  10943. æFp Errors.p
  10944. æC tk0BadErr = -76; {track 0 detect doesn't change}
  10945.  
  10946. æKY tmfoErr
  10947. æFp Errors.p
  10948. æC tmfoErr = -42; {too many files open}
  10949.  
  10950. æKY tmwdoErr
  10951. æFp Errors.p
  10952. æC tmwdoErr = -121; {No free WDCB available}
  10953.  
  10954. æKY tooManyReqs
  10955. æFp Errors.p
  10956. æC tooManyReqs = -1097;
  10957.  
  10958. æKY tooManySkts
  10959. æFp Errors.p
  10960. æC tooManySkts = -1098;
  10961.  
  10962. æKY twoSideErr
  10963. æFp Errors.p
  10964. æC twoSideErr = -78; {tried to read 2nd side on a 1-sided drive}
  10965.  
  10966. æKY unimpErr
  10967. æFp Errors.p
  10968. æC unimpErr = -4; {unimplemented core routine}
  10969.  
  10970. æKY unitEmptyErr
  10971. æFp Errors.p
  10972. æC unitEmptyErr = -22; {I/O System Errors}
  10973.  
  10974. æKY unitTblFullErr
  10975. æFp Errors.p
  10976. æC unitTblFullErr = -29; {unit table has no more entries}
  10977.  
  10978. æKY updPixMemErr
  10979. æFp Errors.p
  10980. æC updPixMemErr = -125; {insufficient memory to update a pixmap}
  10981.  
  10982. æKY userBreak
  10983. æFp Errors.p
  10984. æC userBreak = -490; {user debugger break}
  10985.  
  10986. æKY verErr
  10987. æFp Errors.p
  10988. æC verErr = -84; {track failed to verify}
  10989.  
  10990. æKY vLckdErr
  10991. æFp Errors.p
  10992. æC vLckdErr = -46; {volume is locked}
  10993.  
  10994. æKY volGoneErr
  10995. æFp Errors.p
  10996. æC volGoneErr = -124; {Server volume has been disconnected.}
  10997.  
  10998. æKY volOffLinErr
  10999. æFp Errors.p
  11000. æC volOffLinErr = -53; {volume not on line error (was Ejected)}
  11001.  
  11002. æKY volOnLinErr
  11003. æFp Errors.p
  11004. æC volOnLinErr = -55; {drive volume already on-line at MountVol}
  11005.  
  11006. æKY vTypErr
  11007. æFp Errors.p
  11008. æC vTypErr = -2; {invalid queue element}
  11009.  
  11010. æKY wPrErr
  11011. æFp Errors.p
  11012. æC wPrErr = -44; {diskette is write protected.}
  11013.  
  11014. æKY wrgVolTypErr
  11015. æFp Errors.p
  11016. æC wrgVolTypErr = -123; {Wrong volume type error [operation not supported for MFS]}
  11017.  
  11018. æKY writErr
  11019. æFp Errors.p
  11020. æC writErr = -20; {I/O System Errors}
  11021.  
  11022. æKY wrPermErr
  11023. æFp Errors.p
  11024. æC wrPermErr = -61; {write permissions error}
  11025.  
  11026. æKY wrUnderrun
  11027. æFp Errors.p
  11028. æC wrUnderrun = -74; {write underrun occurred}
  11029.  
  11030.  
  11031. æKY Events.p
  11032. æKL Button
  11033. EventAvail
  11034. GetCaretTime
  11035. GetDblTime
  11036. GetKeys
  11037. GetMouse
  11038. GetNextEvent
  11039. KeyTrans
  11040. StillDown
  11041. TickCount
  11042. WaitMouseUp
  11043. WaitNextEvent
  11044.  
  11045. activateEvt
  11046. activeFlag
  11047. activMask
  11048. adbAddrMask
  11049. alphaLock
  11050. app1Evt
  11051. app1Mask
  11052. app2Evt
  11053. app2Mask
  11054. app3Evt
  11055. app3Mask
  11056. app4Evt
  11057. app4Mask
  11058. autoKey
  11059. autoKeyMask
  11060. btnState
  11061. charCodeMask
  11062. cmdKey
  11063. controlKey
  11064. diskEvt
  11065. diskMask
  11066. driverEvt
  11067. driverMask
  11068. EventRecord
  11069. everyEvent
  11070. keyCodeMask
  11071. keyDown
  11072. keyDownMask
  11073. KeyMap
  11074. KeyTrans
  11075. KeyTrans
  11076. keyUp
  11077. keyUpMask
  11078. mDownMask
  11079. mouseDown
  11080. mouseUp
  11081. mUpMask
  11082. networkEvt
  11083. networkMask
  11084. nullEvent
  11085. optionKey
  11086. shiftKey
  11087. StillDown
  11088. StillDown
  11089. TickCount
  11090. TickCount
  11091. updateEvt
  11092. updateMask
  11093.  
  11094. æKY activeFlag,btnState,cmdKey,shiftKey,alphaLock,optionKey,controlKey
  11095. æFp Events.p
  11096. æC 
  11097. »Modifier Flags
  11098.  
  11099. As mentioned above, the modifiers field of an event record contains further information
  11100. about activate events and the state of the modifier keys and mouse button at the time
  11101. the event was posted (see Figure 7). You might look at this field to find out, for
  11102. instance, whether the Command key was down when a mouse-down event was posted (which
  11103. in many applications affects the way objects are selected) or when a key-down event
  11104. was posted (which could mean the user is choosing a menu item by typing its keyboard
  11105. equivalent).
  11106.  
  11107. •••Refer to Figure 7.•••
  11108.  
  11109. Figure 7–Modifier Flags
  11110.  
  11111. The following predefined constants are useful as masks for reading the flags in the
  11112. modifiers field:
  11113.  
  11114. CONST  activeFlag = 1;     {set if window being activated}
  11115.        btnState   = 128;   {set if mouse button up}
  11116.        cmdKey     = 256;   {set if Command key down}
  11117.        shiftKey   = 512;   {set if Shift key down}
  11118.        alphaLock  = 1024;  {set if Caps Lock key down}
  11119.        optionKey  = 2048;  {set if Option key down}
  11120.        controlKey = 4096;  {set if Control key down}
  11121.  
  11122. The activeFlag bit gives further information about activate events; it’s set if the
  11123. window pointed to by the event message is being activated, or 0 if the window is
  11124. being deactivated. The remaining bits indicate the state of the mouse button and
  11125. modifier keys. Notice that the btnState bit is set if the mouse button is up, whereas
  11126. the bits for the four modifier keys are set if their corresponding keys are down.
  11127.  
  11128. æKY adbAddrMask
  11129. æFp Events.p
  11130. æC adbAddrMask = $00FF0000;
  11131.  
  11132. æKY Button
  11133. æFp Events.p
  11134. æT FUNCTION
  11135. æTN $A974
  11136. æD FUNCTION Button: BOOLEAN;
  11137. æDT myVariable := Button;
  11138. æMM   
  11139. æRI Button function I-259
  11140. æC 
  11141. The Button function returns TRUE if the mouse button is currently down, and FALSE if
  11142. it isn’t.
  11143.  
  11144. æKY charCodeMask,keyCodeMask
  11145. æFp Events.p
  11146. æC 
  11147. The following predefined constants are available to help you access the character
  11148. code and key code:
  11149.  
  11150. CONST  charCodeMask = $000000FF;    {character code}
  11151.        keyCodeMask  = $0000FF00;    {key code}
  11152.  
  11153. æKY EventAvail
  11154. æFp Events.p
  11155. æT FUNCTION
  11156. æTN $A971
  11157. æD FUNCTION EventAvail(eventMask: INTEGER;VAR theEvent: EventRecord): BOOLEAN;
  11158. æDT myVariable := EventAvail(eventMask,theEvent);
  11159. æMM 
  11160. æRT 194
  11161. æRI EventAvail function I-259
  11162. æC 
  11163. EventAvail works exactly the same as GetNextEvent except that if the event is in the
  11164. event queue, it’s left there.
  11165.  
  11166. Note:  An event returned by EventAvail will not be accessible later if in
  11167.        the meantime the queue becomes full and the event is discarded from
  11168.        it; since the events discarded are always the oldest ones in the queue,
  11169.        however, this will happen only in an unusually busy environment.
  11170.  
  11171. æKY EventRecord
  11172. æFp Events.p
  11173. æT RECORD
  11174. æC EventRecord = RECORD
  11175.    what: INTEGER;
  11176.    message: LONGINT;
  11177.    when: LONGINT;
  11178.    where: Point;
  11179.    modifiers: INTEGER;
  11180.    END;
  11181.  
  11182. _______________________________________________________________________________
  11183.  
  11184. »EVENT RECORDS
  11185. _______________________________________________________________________________
  11186.  
  11187. Every event is represented internally by an event record containing all pertinent
  11188. information about that event. The event record includes the following information:
  11189.  
  11190.   •  the type of event
  11191.   •  the time the event was posted (in ticks since system startup)
  11192.   •  the location of the mouse at the time the event was posted (in global
  11193.      coordinates)
  11194.   •  the state of the mouse button and modifier keys at the time the event
  11195.      was posted
  11196.   •  any additional information required for a particular type of event, such
  11197.      as which key the user pressed or which window is being activated
  11198.  
  11199. Every event has an event record containing this information—even null events.
  11200.  
  11201. Event records are defined as follows:
  11202.  
  11203. TYPE  EventRecord = RECORD
  11204.                       what:       INTEGER;  {event code}
  11205.                       message:    LONGINT;  {event message}
  11206.                       when:       LONGINT;  {ticks since startup}
  11207.                       where:      Point;    {mouse location}
  11208.                       modifiers:  INTEGER   {modifier flags}
  11209.                     END;
  11210.  
  11211. The when field contains the number of ticks since the system last started up, and the
  11212. where field gives the location of the mouse, in global coordinates, at the time the
  11213. event was posted. The other three fields are described below.
  11214.  
  11215. _______________________________________________________________________________
  11216.  
  11217. »Event Code
  11218.  
  11219. The what field of an event record contains an event code identifying the type of the
  11220. event. The event codes are available as predefined constants:
  11221.  
  11222. CONST  nullEvent   =  0;    {null}
  11223.        mouseDown   =  1;    {mouse-down}
  11224.        mouseUp     =  2;    {mouse-up}
  11225.        keyDown     =  3;    {key-down}
  11226.        keyUp       =  4;    {key-up}
  11227.        autoKey     =  5;    {auto-key}
  11228.        updateEvt   =  6;    {update}
  11229.        diskEvt     =  7;    {disk-inserted}
  11230.        activateEvt =  8;    {activate}
  11231.        networkEvt  = 10;    {network}
  11232.        driverEvt   = 11;    {device driver}
  11233.        app1Evt     = 12;    {application-defined}
  11234.        app2Evt     = 13;    {application-defined}
  11235.        app3Evt     = 14;    {application-defined}
  11236.        app4Evt     = 15;    {application-defined}
  11237.  
  11238. _______________________________________________________________________________
  11239.  
  11240. »Event Message
  11241.  
  11242. The message field of an event record contains the event message, which conveys additional
  11243. important information about the event. The nature of this information depends on the
  11244. event type, as summarized in the following table and described below.
  11245.  
  11246.   Event type             Event message
  11247.  
  11248.   Keyboard               Character code, key code, and ADB address field
  11249.   Activate, update       Pointer to window
  11250.   Disk-inserted          Drive number in low-order word, File Manager
  11251.                          result code in high-order word
  11252.   Mouse-down,            Undefined
  11253.   mouse-up, null
  11254.   Network                Handle to parameter block
  11255.   Device driver          See chapter describing driver
  11256.   Application-defined    Whatever you wish
  11257.  
  11258. For keyboard events, the low-order byte of the low-order word of the event message
  11259. contains the ASCII character code generated by the key or combination of keys that
  11260. was pressed or released; usually this is all you’ll need.  However, as described in
  11261. the Apple Desktop Bus chapter, the Macintosh II and SE can be connected to multiple
  11262. keyboards.  To identify the origin of keyboard events, the keyboard event message
  11263. contains a new ADB address field.  It now has the structure shown in Figure 2.
  11264.  
  11265. Warning:  The high byte of the event message for keyboard events is reserved
  11266.           for future use, and is not presently guaranteed to be zero.
  11267.  
  11268. The event message for non-keyboard events remains the same as described above.
  11269.  
  11270. •••Refer to Figure 2.•••
  11271.  
  11272. Figure 2–Event Message for Keyboard Events
  11273.  
  11274. The key code in the event message for a keyboard event represents the character key
  11275. that was pressed or released; this value is always the same for any given character
  11276. key, regardless of the modifier keys pressed along with it. Key codes are useful in
  11277. special cases—in a music generator, for example—where you want to treat the keyboard
  11278. as a set of keys unrelated to characters. Figure 3 gives the key codes for all the
  11279. keys on the keyboard and keypad. (Key codes are shown for modifier keys here because
  11280. they’re meaningful in other contexts, as explained later.) Both the U.S. and international
  11281. keyboards are shown; in some cases the codes are quite different (for example, space
  11282. and Enter are reversed).
  11283.  
  11284. Three keyboards are now available as standard equipment with Macintosh computers sold
  11285. in the U.S.  They are
  11286.  
  11287.   •  The Macintosh Plus Keyboard, which includes cursor control keys and an
  11288.      integral keypad.  Its layout and key coding is shown in Figure 4.
  11289.   •  The Macintosh II Keyboard, also shipped with the Macintosh SE, which
  11290.      adds Esc (Escape) and Control keys and is connected to the Apple Desktop
  11291.      Bus.  Its layout and key coding is shown in Figure 5.
  11292.   •  The Apple Extended Keyboard,  which the user may connect to the Apple
  11293.      Desktop Bus of any Macintosh II or Macintosh SE computer.  Its layout
  11294.      and key coding is shown in Figure 6.
  11295.  
  11296. These figures show the virtual key codes for each key; they are the key codes that
  11297. actually appear in keyboard events.  In the case of the Macintosh II and Apple Extended
  11298. Keyboards, however, the hardware produces raw key codes, which may be different.  Raw
  11299. key codes are translated to virtual key codes by the
  11300. 'KMAP' resource in the System Folder.  By modifying the 'KMAP' resource you can
  11301. change the key codes for any keys.  Similarly, you can change the ASCII codes corresponding
  11302. to specific key codes by modifying the 'KCHR' resource in the System Folder.  The
  11303. 'KMAP' and 'KCHR' resources are described in the Resource Manager chapter.
  11304.  
  11305. With both the Macintosh II and the Apple Extended keyboards, the standard 'KMAP'
  11306. resource supplied in the system folder reassigns the following raw key codes to
  11307. different virtual key codes:
  11308.  
  11309.   Key           Raw key code    Virtual key code
  11310.  
  11311.   Control           36                3B
  11312.   Left cursor       3B                7B
  11313.   Right cursor      3C                7C
  11314.   Down cursor       3D                7D
  11315.   Up cursor         3E                7E
  11316.  
  11317. The standard 'KMAP' resource leaves all other raw key codes and virtual key codes the
  11318. same.
  11319.  
  11320. With the Apple Extended Keyboard, the virtual key codes for three more keys may be
  11321. easily reassigned, as described above under “Reassigning Right Key Codes”.
  11322.  
  11323. The following predefined constants are available to help you access the character
  11324. code and key code:
  11325.  
  11326. CONST  charCodeMask = $000000FF;    {character code}
  11327.        keyCodeMask  = $0000FF00;    {key code}
  11328.  
  11329. •••Refer to Figure 3.•••
  11330.  
  11331. Figure 3–Key Codes
  11332.  
  11333. •••Refer to Figure 4.•••
  11334.  
  11335. Figure 4–Macintosh Plus Keyboard
  11336.  
  11337. •••Refer to Figure 5.•••
  11338.  
  11339. Figure 5–Macintosh II Keyboard
  11340.  
  11341. •••Refer to Figure 6.•••
  11342.  
  11343. Figure 6–Apple Extended Keyboard
  11344.  
  11345. Note:  You can use the Toolbox Utility function BitAnd with these constants;
  11346.        for instance, to access the character code, use
  11347.  
  11348.          charCode := BitAnd(my Event.message,charCodeMask)
  11349. _______________________________________________________________________________
  11350.  
  11351. THE TOOLBOX EVENT MANAGER                                           
  11352. _______________________________________________________________________________
  11353.  
  11354. For activate and update events, the event message is a pointer to the window affected.
  11355. (If the event is an activate event, additional important information about the event
  11356. can be found in the modifiers field of the event record, as described below.)
  11357.  
  11358. For disk-inserted events, the low-order word of the event message contains the drive
  11359. number of the disk drive into which the disk was inserted:  1 for the Macintosh’s
  11360. built-in drive, and 2 for the external drive, if any. Numbers greater than 2 denote
  11361. additional disk drives connected to the Macintosh. By the time your application
  11362. receives a disk-inserted event, the system will already have attempted to mount the
  11363. volume on the disk by calling the File Manager function MountVol; the high-order word
  11364. of the event message will contain the result code returned by MountVol.
  11365.  
  11366. For mouse-down, mouse-up, and null events, the event message is undefined and should
  11367. be ignored. The event message for a network event contains a handle to a parameter
  11368. block, as described in the AppleTalk Manager chapter. For device driver events, the
  11369. contents of the event message depend on the situation under which the event was
  11370. generated; the chapters describing those situations will give the details. Finally,
  11371. you can use the event message however you wish for application-defined event types.
  11372.  
  11373. _______________________________________________________________________________
  11374.  
  11375. »Modifier Flags
  11376.  
  11377. As mentioned above, the modifiers field of an event record contains further information
  11378. about activate events and the state of the modifier keys and mouse button at the time
  11379. the event was posted (see Figure 7). You might look at this field to find out, for
  11380. instance, whether the Command key was down when a mouse-down event was posted (which
  11381. in many applications affects the way objects are selected) or when a key-down event
  11382. was posted (which could mean the user is choosing a menu item by typing its keyboard
  11383. equivalent).
  11384.  
  11385. •••Refer to Figure 7.•••
  11386.  
  11387. Figure 7–Modifier Flags
  11388.  
  11389. The following predefined constants are useful as masks for reading the flags in the
  11390. modifiers field:
  11391.  
  11392. CONST  activeFlag = 1;     {set if window being activated}
  11393.        btnState   = 128;   {set if mouse button up}
  11394.        cmdKey     = 256;   {set if Command key down}
  11395.        shiftKey   = 512;   {set if Shift key down}
  11396.        alphaLock  = 1024;  {set if Caps Lock key down}
  11397.        optionKey  = 2048;  {set if Option key down}
  11398.        controlKey = 4096;  {set if Control key down}
  11399.  
  11400. The activeFlag bit gives further information about activate events; it’s set if the
  11401. window pointed to by the event message is being activated, or 0 if the window is
  11402. being deactivated. The remaining bits indicate the state of the mouse button and
  11403. modifier keys. Notice that the btnState bit is set if the mouse button is up, whereas
  11404. the bits for the four modifier keys are set if their corresponding keys are down.
  11405.  
  11406. æKY everyEvent
  11407. æFp Events.p
  11408. æC everyEvent = -1;
  11409.  
  11410. æKY GetCaretTime
  11411. æFp Events.p
  11412. æT FUNCTION
  11413. æD FUNCTION GetCaretTime: LONGINT;
  11414. æDT myVariable := GetCaretTime;
  11415. æRI GetCaretTime function I-260
  11416. æC 
  11417. [Not in ROM]
  11418.  
  11419. GetCaretTime returns the time (in ticks) between blinks of the “caret” (usually a
  11420. vertical bar) marking the insertion point in editable text. If you aren’t using
  11421. TextEdit, you’ll need to cause the caret to blink yourself; on every pass through
  11422. your program’s main event loop, you should check this value against the elapsed time
  11423. since the last blink of the caret. The user can adjust this value by means of the
  11424. Control Panel desk accessory.
  11425.  
  11426. Assembly-language note:  This value is available to assembly-language
  11427.                          programmers in the global variable CaretTime.
  11428.  
  11429. æKY GetDblTime
  11430. æFp Events.p
  11431. æT FUNCTION
  11432. æD FUNCTION GetDblTime: LONGINT;
  11433. æDT myVariable := GetDblTime;
  11434. æRI GetDblTime function I-260
  11435. æC 
  11436. [Not in ROM]
  11437.  
  11438. GetDblTime returns the suggested maximum difference (in ticks) that should exist
  11439. between the times of a mouse-up event and a mouse-down event for those two mouse
  11440. clicks to be considered a double-click. The user can adjust this value by means of
  11441. the Control Panel desk accessory.
  11442.  
  11443. Assembly-language note:  This value is available to assembly-language
  11444.                          programmers in the global variable DoubleTime.
  11445.  
  11446. æKY GetKeys
  11447. æFp Events.p
  11448. æT PROCEDURE
  11449. æTN $A976
  11450. æD PROCEDURE GetKeys(VAR theKeys: KeyMap);
  11451. æDT GetKeys(theKeys);
  11452. æMM   
  11453. æRI GetKeys procedure I-259
  11454. æC 
  11455. GetKeys reads the current state of the keyboard (and keypad, if any) and returns it
  11456. in the form of a keyMap:
  11457.  
  11458. TYPE KeyMap = PACKED ARRAY[0..127] OF BOOLEAN;
  11459.  
  11460. Each key on the keyboard or keypad corresponds to an element in the keyMap. The index
  11461. into the keyMap for a particular key is the same as the key code for that key. (The
  11462. key codes are shown in Figure 3 above.) The keyMap element is TRUE if the corresponding
  11463. key is down and FALSE if it isn’t. The maximum number of keys that can be down simultaneously
  11464. is two character keys plus any combination of the four modifier keys.
  11465.  
  11466. æKY GetMouse
  11467. æFp Events.p
  11468. æT PROCEDURE
  11469. æTN $A972
  11470. æD PROCEDURE GetMouse(VAR mouseLoc: Point);
  11471. æDT GetMouse(mouseLoc);
  11472. æMM   
  11473. æRI GetMouse procedure I-259
  11474. æC  
  11475. GetMouse returns the current mouse location in the mouseLoc parameter. The location
  11476. is given in the local coordinate system of the current grafPort (which might be, for
  11477. example, the currently active window). Notice that this differs from the mouse location
  11478. stored in the where field of an event record; that location is always in global
  11479. coordinates.
  11480.  
  11481. æKY GetNextEvent
  11482. æFp Events.p
  11483. æT FUNCTION
  11484. æTN $A970
  11485. æD FUNCTION GetNextEvent(eventMask: INTEGER;VAR theEvent: EventRecord): BOOLEAN;
  11486. æDT myVariable := GetNextEvent(eventMask,theEvent);
  11487. æMM 
  11488. æRT 3, 5, 85, 194, 205 
  11489. æRI GetNextEvent function I-257, N3-1, N5-1, N85, P-30, 32, 34, 39, 40, 97, 108, 173
  11490. æC 
  11491. GetNextEvent returns the next available event of a specified type or types and, if
  11492. the event is in the event queue, removes it from the queue. The event is returned in
  11493. the parameter theEvent. The eventMask parameter specifies which event types are of
  11494. interest. GetNextEvent returns the next available event of any type designated by the
  11495. mask, subject to the priority rules discussed above under “Priority of Events”. If no
  11496. event of any of the designated types is available, GetNextEvent returns a null event.
  11497.  
  11498. Note:  Events in the queue that aren’t designated in the mask are kept in
  11499.        the queue; if you want to remove them, you can do so by calling the
  11500.        Operating System Event Manager procedure FlushEvents.
  11501.  
  11502. Before reporting an event to your application, GetNextEvent first calls the Desk
  11503. Manager function SystemEvent to see whether the system wants to intercept and respond
  11504. to the event. If so, or if the event being reported is a null event, GetNextEvent
  11505. returns a function result of FALSE; a function result of TRUE means that your application
  11506. should handle the event itself. The Desk Manager intercepts the following events:
  11507.  
  11508.   •  activate and update events directed to a desk accessory
  11509.   •  mouse-up and keyboard events, if the currently active window belongs to
  11510.      a desk accessory
  11511.  
  11512. Note:  In each case, the event is intercepted by the Desk Manager only if
  11513.        the desk accessory can handle that type of event; however, as a rule
  11514.        all desk accessories should be set up to handle activate, update, and
  11515.        keyboard events and should not handle mouse-up events.
  11516.  
  11517. The Desk Manager also intercepts disk-inserted events:  It attempts to mount the
  11518. volume on the disk by calling the File Manager function MountVol. GetNextEvent will
  11519. always return TRUE in this case, though, so that your application can take any further
  11520. appropriate action after examining the result code returned by MountVol in the event
  11521. message. (See the Desk Manager and File Manager chapters.) GetNextEvent returns TRUE
  11522. for all other non-null events
  11523. (including all mouse-down events, regardless of which window is active), leaving them
  11524. for your application to handle.
  11525.  
  11526. GetNextEvent also makes the following processing happen, invisible to your program:
  11527.  
  11528.   •  If the “alarm” is set and the current time is the alarm time, the alarm
  11529.      goes off (a beep followed by blinking the apple symbol in the menu bar).
  11530.      The user can set the alarm with the Alarm Clock desk accessory.
  11531.   •  If the user holds down the Command and Shift keys while pressing a
  11532.      numeric key that has a special effect, that effect occurs. The standard
  11533.      such keys are 1 and 2 for ejecting the disk in the internal or external
  11534.      drive, and 3 and 4 for writing a snapshot of the screen to a MacPaint
  11535.      document or to the printer.
  11536.  
  11537. Note:  Advanced programmers can implement their own code to be executed in
  11538.        response to Command-Shift-number combinations (except for Command-
  11539.        Shift-1 and 2, which can’t be changed). The code corresponding to a
  11540.        particular number must be a routine having no parameters, stored in
  11541.        a resource whose type is 'FKEY' and whose ID is the number. The
  11542.        system resource file contains code for the numbers 3 and 4.
  11543.  
  11544. Assembly-language note:  You can disable GetNextEvent’s processing of Command-
  11545.                          Shift-number combinations by setting the global
  11546.                          variable ScrDmpEnb (a byte) to 0.
  11547.  
  11548. æKY KeyMap
  11549. æFp Events.p
  11550. æT TYPE
  11551. æC KeyMap = PACKED ARRAY [0..127] OF BOOLEAN;
  11552.  
  11553. æKY mDownMask,mUpMask,keyDownMask,keyUpMask,autoKeyMask,updateMask,diskMask,activMask,networkMask,driverMask,app1Mask,app2Mask,app3Mask,app4Mask
  11554. æFp Events.p
  11555. æC 
  11556. _______________________________________________________________________________
  11557.  
  11558. »EVENT MASKS
  11559. _______________________________________________________________________________
  11560.  
  11561. Some of the Event Manager routines can be restricted to operate on a specific event
  11562. type or group of types; in other words, the specified event types are enabled while
  11563. all others are disabled. For instance, instead of just requesting the next available
  11564. event, you can specifically ask for the next keyboard event.
  11565.  
  11566. You specify which event types a particular Event Manager call applies to by supplying
  11567. an event mask as a parameter. This is an integer in which there’s one bit position
  11568. for each event type, as shown in Figure 8. The bit position representing a given type
  11569. corresponds to the event code for that type—for example, update events (event code 6)
  11570. are specified by bit 6 of the mask. A 1 in bit 6 means that this Event Manager call
  11571. applies to update events; a 0 means that it doesn’t.
  11572.  
  11573. •••Refer to Figure 8.•••
  11574.  
  11575. Figure 8–Event Mask
  11576.  
  11577. Masks for each individual event type are available as predefined constants:
  11578.  
  11579. CONST  mDownMask   = 2;       {mouse-down}
  11580.        mUpMask     = 4;       {mouse-up}
  11581.        keyDownMask = 8;       {key-down}
  11582.        keyUpMask   = 16;      {key-up}
  11583.        autoKeyMask = 32;      {auto-key}
  11584.        updateMask  = 64;      {update}
  11585.        diskMask    = 128;     {disk-inserted}
  11586.        activMask   = 256;     {activate}
  11587.        networkMask = 1024;    {network}
  11588.        driverMask  = 2048;    {device driver}
  11589.        app1Mask    = 4096;    {application-defined}
  11590.        app2Mask    = 8192;    {application-defined}
  11591.        app3Mask    = 16384;   {application-defined}
  11592.        app4Mask    = -32768;  {application-defined}
  11593.  
  11594. Note:  Null events can’t be disabled; a null event will always be reported
  11595.        when none of the enabled types of events are available.
  11596.  
  11597. The following predefined mask designates all event types:
  11598.  
  11599. CONST    everyEvent    = -1;    {all event types}
  11600.  
  11601. You can form any mask you need by adding or subtracting these mask constants. For
  11602. example, to specify every keyboard event, use
  11603.  
  11604.   keyDownMask + keyUpMask + autoKeyMask
  11605.  
  11606. For every event except an update, use
  11607.  
  11608.   everyEvent - updateMask
  11609.  
  11610. Note:  It’s recommended that you always use the event mask everyEvent unless
  11611.        there’s a specific reason not to.
  11612.  
  11613. There’s also a global system event mask that controls which event types get posted
  11614. into the event queue. Only event types corresponding to bits set in the system event
  11615. mask are posted; all others are ignored. When the system starts up, the system event
  11616. mask is set to post all except key-up event—that is, it’s initialized to
  11617.  
  11618.   everyEvent - keyUpMask
  11619.  
  11620. Note:  Key-up events are meaningless for most applications. Your application
  11621.        will usually want to ignore them; if not, it can set the system event
  11622.        mask with the Operating System Event Manager procedure SetEventMask.
  11623.  
  11624. æKY nullEvent,mouseDown,mouseUp,keyDown,keyUp,autoKey,updateEvt,diskEvt,activateEvt,networkEvt,driverEvt,app1Evt,app2Evt,app3Evt,app4Evt
  11625. æFp Events.p
  11626. æC 
  11627. »Event Code
  11628.  
  11629. The what field of an event record contains an event code identifying the type of the
  11630. event. The event codes are available as predefined constants:
  11631.  
  11632. CONST  nullEvent   =  0;    {null}
  11633.        mouseDown   =  1;    {mouse-down}
  11634.        mouseUp     =  2;    {mouse-up}
  11635.        keyDown     =  3;    {key-down}
  11636.        keyUp       =  4;    {key-up}
  11637.        autoKey     =  5;    {auto-key}
  11638.        updateEvt   =  6;    {update}
  11639.        diskEvt     =  7;    {disk-inserted}
  11640.        activateEvt =  8;    {activate}
  11641.        networkEvt  = 10;    {network}
  11642.        driverEvt   = 11;    {device driver}
  11643.        app1Evt     = 12;    {application-defined}
  11644.        app2Evt     = 13;    {application-defined}
  11645.        app3Evt     = 14;    {application-defined}
  11646.        app4Evt     = 15;    {application-defined}
  11647.  
  11648.  
  11649. æKY StillDown
  11650. æFp Events.p
  11651. æT FUNCTION
  11652. æTN $A973
  11653. æD FUNCTION StillDown: BOOLEAN;
  11654. æDT myVariable := StillDown;
  11655. æMM 
  11656. æRT 194
  11657. æRI StillDown function I-259
  11658. æC 
  11659. Usually called after a mouse-down event, StillDown tests whether the mouse button is
  11660. still down. It returns TRUE if the button is currently down and there are no more
  11661. mouse events pending in the event queue. This is a true test of whether the button is
  11662. still down from the original press—unlike Button (above), which returns TRUE whenever
  11663. the button is currently down, even if it has been released and pressed again since
  11664. the original mouse-down event.
  11665.  
  11666. æKY TickCount
  11667. æFp Events.p
  11668. æT FUNCTION
  11669. æTN $A975
  11670. æD FUNCTION TickCount: LONGINT;
  11671. æDT myVariable := TickCount;
  11672. æMM   
  11673. æRI TickCount function I-260
  11674. æC 
  11675. TickCount returns the current number of ticks (sixtieths of a second) since the
  11676. system last started up.
  11677.  
  11678. Warning:  Don’t rely on the tick count being exact; it will usually be
  11679.           accurate to within one tick, but may be off by more than that. The
  11680.           tick count is incremented during the vertical retrace interrupt,
  11681.           but it’s possible for this interrupt to be disabled. Furthermore,
  11682.           don’t rely on the tick count being incremented to a certain value,
  11683.           such as testing whether it has become equal to its old value plus 1;
  11684.           check instead for “greater than or equal to” (since an interrupt
  11685.           task may keep control for more than one tick).
  11686.  
  11687. Assembly-language note:  The value returned by this function is also contained
  11688.                          in the global variable Ticks.
  11689.  
  11690. æKY WaitMouseUp
  11691. æFp Events.p
  11692. æT FUNCTION
  11693. æTN $A977
  11694. æD FUNCTION WaitMouseUp: BOOLEAN;
  11695. æDT myVariable := WaitMouseUp;
  11696. æMM 
  11697. æRT 194
  11698. æRI WaitMouseUp function I-259
  11699. æC 
  11700. WaitMouseUp works exactly the same as StillDown (above), except that if the button is
  11701. not still down from the original press, WaitMouseUp removes the preceding mouse-up
  11702. event before returning FALSE. If, for instance, your application attaches some special
  11703. significance both to mouse double-clicks and to mouse-up events, this function would
  11704. allow your application to recognize a double-click without being confused by the
  11705. intervening mouse-up.
  11706.  
  11707. æKY WaitNextEvent
  11708. æFp Events.p
  11709. æT FUNCTION
  11710. æTN $A860
  11711. æD FUNCTION WaitNextEvent(mask: INTEGER;VAR event: EventRecord;sleep: LONGINT;
  11712.     mouseRgn: RgnHandle): BOOLEAN;
  11713. æDT myVariable := WaitNextEvent(mask,event,sleep,mouseRgn);
  11714. æRT 158, 177, 180, 194, 205
  11715. æRI WaitNextEvent N158-1
  11716.  
  11717.  
  11718.  
  11719. æKY Files.p
  11720. æKL AddDrive
  11721. Allocate
  11722. AllocContig
  11723. CatMove
  11724. CloseWD
  11725. Create
  11726. DirCreate
  11727. Eject
  11728. FInitQueue
  11729. FlushVol
  11730. FSClose
  11731. FSDelete
  11732. FSOpen
  11733. FSOpenFile
  11734. FSRead
  11735. FSWrite
  11736. GetDrvQHdr
  11737. GetEOF
  11738. GetFInfo
  11739. GetFPos
  11740. GetFSQHdr
  11741. GetVCBQHdr
  11742. GetVInfo
  11743. GetVol
  11744. GetVRefNum
  11745. GetWDInfo
  11746. HCreate
  11747. HDelete
  11748. HGetFInfo
  11749. HGetVol
  11750. HOpen
  11751. HOpenFile
  11752. HOpenRF
  11753. HRename
  11754. HRstFLock
  11755. HSetFInfo
  11756. HSetFLock
  11757. HSetVol
  11758. OpenRF
  11759. OpenWD
  11760. PBAllocate
  11761. PBAllocContig
  11762. PBCatMove
  11763. PBClose
  11764. PBCloseWD
  11765. PBCreate
  11766. PBDelete
  11767. PBDirCreate
  11768. PBEject
  11769. PBFlushFile
  11770. PBFlushVol
  11771. PBGetCatInfo
  11772. PBGetEOF
  11773. PBGetFCBInfo
  11774. PBGetFInfo
  11775. PBGetFPos
  11776. PBGetVInfo
  11777. PBGetVol
  11778. PBGetWDInfo
  11779. PBHCopyFile
  11780. PBHCreate
  11781. PBHDelete
  11782. PBHGetDirAccess
  11783. PBHGetFInfo
  11784. PBHGetLogInInfo
  11785. PBHGetVInfo
  11786. PBHGetVol
  11787. PBHGetVolParms
  11788. PBHMapID
  11789. PBHMapName
  11790. PBHMoveRename
  11791. PBHOpen
  11792. PBHOpenDeny
  11793. PBHOpenFile
  11794. PBHOpenRF
  11795. PBHOpenRFDeny
  11796. PBHRename
  11797. PBHRstFLock
  11798. PBHSetDirAccess
  11799. PBHSetFInfo
  11800. PBHSetFLock
  11801. PBHSetVol
  11802. PBLockRange
  11803. PBMountVol
  11804. PBOffLine
  11805. PBOpen
  11806. PBOpenFile
  11807. PBOpenRF
  11808. PBOpenWD
  11809. PBRead
  11810. PBRename
  11811. PBRstFLock
  11812. PBSetCatInfo
  11813. PBSetEOF
  11814. PBSetFInfo
  11815. PBSetFLock
  11816. PBSetFPos
  11817. PBSetFVers
  11818. PBSetVInfo
  11819. PBSetVol
  11820. PBUnlockRange
  11821. PBUnmountVol
  11822. PBWrite
  11823. Rename
  11824. RstFLock
  11825. SetEOF
  11826. SetFInfo
  11827. SetFLock
  11828. SetFPos
  11829. SetVol
  11830. UnmountVol
  11831.  
  11832. AccessParam
  11833. alphaStage
  11834. betaStage
  11835. CInfoPBPtr
  11836. CInfoPBRec
  11837. CInfoType
  11838. CMovePBPtr
  11839. CMovePBRec
  11840. CntrlParam
  11841. CopyParam
  11842. developStage
  11843. DInfo
  11844. dirInfo
  11845. DXInfo
  11846. FCBPBPtr
  11847. FCBPBRec
  11848. fDesktop
  11849. fDisk
  11850. fHasBundle
  11851. FileParam
  11852. finalStage
  11853. FInfo
  11854. fInvisible
  11855. fOnDesk
  11856. fsAtMark
  11857. fsCurPerm
  11858. fsFromLEOF
  11859. fsFromMark
  11860. fsFromStart
  11861. fsRdPerm
  11862. fsRdWrPerm
  11863. fsRdWrShPerm
  11864. fsRtDirID
  11865. fsRtParID
  11866. fsWrPerm
  11867. fTrash
  11868. FXInfo
  11869. hFileInfo
  11870. HParamBlockRec
  11871. HParmBlkPtr
  11872. ioDirFlg
  11873. ioDirMask
  11874. IOParam
  11875. MultiDevParam
  11876. NumVersion
  11877. ObjParam
  11878. ParamBlkType
  11879. rdVerify
  11880. SlotDevParam
  11881. VCB
  11882. VersRec
  11883. VersRecHndl
  11884. VersRecPtr
  11885. VolumeParam
  11886. WDParam
  11887. WDPBPtr
  11888. WDPBRec
  11889.  
  11890. æKY VersRecHndl,VersRecPtr,VersRec
  11891. æFp Files.p
  11892. æT TYPE
  11893. æC VersRecPtr = ^VersRec;
  11894. VersRecHndl = ^VersRecPtr;
  11895. VersRec = RECORD
  11896.    numericVersion: NumVersion;         {encoded version number}
  11897.    countryCode: INTEGER;               {country code from intl utilities}
  11898.    shortVersion: Str255;               {version number string - worst case}
  11899.    reserved: Str255;                   {longMessage string packed after shortVersion}
  11900.    END;
  11901.  
  11902. æKY WDPBRec,WDPBPtr
  11903. æFp Files.p
  11904. æT TYPE
  11905. æC WDPBPtr = ^WDPBRec;
  11906. WDPBRec = RECORD
  11907.    qLink: QElemPtr;
  11908.    qType: INTEGER;
  11909.    ioTrap: INTEGER;
  11910.    ioCmdAddr: Ptr;
  11911.    ioCompletion: ProcPtr;
  11912.    ioResult: OSErr;
  11913.    ioNamePtr: StringPtr;
  11914.    ioVRefNum: INTEGER;
  11915.    filler1: INTEGER;
  11916.    ioWDIndex: INTEGER;
  11917.    ioWDProcID: LONGINT;
  11918.    ioWDVRefNum: INTEGER;
  11919.    filler2: ARRAY [1..7] OF INTEGER;
  11920.    ioWDDirID: LONGINT;
  11921.    END;
  11922.  
  11923. »WDPBRec
  11924.  
  11925. When you call the routines that open, close, and get information about working directories,
  11926. you’ll use the following six additional fields after the standard eight fields in the
  11927. parameter block record WDPBRec:
  11928.  
  11929.   filler1:      INTEGER;    {not used}
  11930.   ioWDIndex:    INTEGER;    {index}
  11931.   ioWDProcID:   LONGINT;    {working directory user identifier}
  11932.   ioWDVRefNum:  INTEGER;    {working directory's volume reference number}
  11933.   filler2:      ARRAY[1..7] OF INTEGER;  {not used}
  11934.   ioWDDirID:    LONGINT);   {working directory's directory ID}
  11935.  
  11936. IOWDIndex can be used with the function PBGetWDInfo to index through the current
  11937. working directories.
  11938.  
  11939. IOWDProcID is an identifier that’s used to distinguish between working directories
  11940. set up by different users; you should use the application’s signature (discussed in
  11941. the Finder Interface chapter) as the ioWDProcID.
  11942.  
  11943. æKY ParamBlkType,IOParam,FileParam,VolumeParam,CntrlParam,SlotDevParam,MultiDevParam,AccessParam,ObjParam,CopyParam,WDParam
  11944. æFp Files.p
  11945. æC ParamBlkType = (IOParam,FileParam,VolumeParam,CntrlParam,SlotDevParam,
  11946. MultiDevParam,AccessParam,ObjParam,CopyParam,WDParam);
  11947.  
  11948. æKY HParamBlockRec,HParmBlkPtr
  11949. æFp Files.p
  11950. æT TYPE
  11951. æC HParmBlkPtr = ^HParamBlockRec;
  11952. HParamBlockRec = RECORD
  11953.    qLink: QElemPtr;
  11954.    qType: INTEGER;
  11955.    ioTrap: INTEGER;
  11956.    ioCmdAddr: Ptr;
  11957.    ioCompletion: ProcPtr;
  11958.    ioResult: OSErr;
  11959.    ioNamePtr: StringPtr;
  11960.    ioVRefNum: INTEGER;
  11961.    CASE ParamBlkType OF
  11962.      IOParam:
  11963.        (ioRefNum: INTEGER;
  11964.        ioVersNum: SignedByte;
  11965.        ioPermssn: SignedByte;
  11966.        ioMisc: Ptr;
  11967.        ioBuffer: Ptr;
  11968.        ioReqCount: LONGINT;            {size of buffer area}
  11969.        ioActCount: LONGINT;            {length of vol parms data}
  11970.        ioPosMode: INTEGER;
  11971.        ioPosOffset: LONGINT);
  11972.      FileParam:
  11973.        (ioFRefNum: INTEGER;
  11974.        ioFVersNum: SignedByte;
  11975.        filler1: SignedByte;
  11976.        ioFDirIndex: INTEGER;
  11977.        ioFlAttrib: SignedByte;
  11978.        ioFlVersNum: SignedByte;
  11979.        ioFlFndrInfo: FInfo;
  11980.        ioDirID: LONGINT;
  11981.        ioFlStBlk: INTEGER;
  11982.        ioFlLgLen: LONGINT;
  11983.        ioFlPyLen: LONGINT;
  11984.        ioFlRStBlk: INTEGER;
  11985.        ioFlRLgLen: LONGINT;
  11986.        ioFlRPyLen: LONGINT;
  11987.        ioFlCrDat: LONGINT;
  11988.        ioFlMdDat: LONGINT);
  11989.      VolumeParam:
  11990.        (filler2: LONGINT;
  11991.        ioVolIndex: INTEGER;
  11992.        ioVCrDate: LONGINT;
  11993.        ioVLsMod: LONGINT;
  11994.        ioVAtrb: INTEGER;
  11995.        ioVNmFls: INTEGER;
  11996.        ioVBitMap: INTEGER;
  11997.        ioAllocPtr: INTEGER;
  11998.        ioVNmAlBlks: INTEGER;
  11999.        ioVAlBlkSiz: LONGINT;
  12000.        ioVClpSiz: LONGINT;
  12001.        ioAlBlSt: INTEGER;
  12002.        ioVNxtCNID: LONGINT;
  12003.        ioVFrBlk: INTEGER;
  12004.        ioVSigWord: INTEGER;
  12005.        ioVDrvInfo: INTEGER;
  12006.        ioVDRefNum: INTEGER;
  12007.        ioVFSID: INTEGER;
  12008.        ioVBkUp: LONGINT;
  12009.        ioVSeqNum: INTEGER;
  12010.        ioVWrCnt: LONGINT;
  12011.        ioVFilCnt: LONGINT;
  12012.        ioVDirCnt: LONGINT;
  12013.        ioVFndrInfo: ARRAY [1..8] OF LONGINT);
  12014.      AccessParam:
  12015.        (filler3: INTEGER;
  12016.        ioDenyModes: INTEGER;           {access rights data}
  12017.        filler4: INTEGER;
  12018.        filler5: SignedByte;
  12019.        ioACUser: SignedByte;           {access rights for directory only}
  12020.        filler6: LONGINT;
  12021.        ioACOwnerID: LONGINT;           {owner ID}
  12022.        ioACGroupID: LONGINT;           {group ID}
  12023.        ioACAccess: LONGINT);           {access rights}
  12024.      ObjParam:
  12025.        (filler7: INTEGER;
  12026.        ioObjType: INTEGER;             {function code}
  12027.        ioObjNamePtr: Ptr;              {ptr to returned creator/group name}
  12028.        ioObjID: LONGINT);              {creator/group ID}
  12029.      CopyParam:
  12030.        (ioDstVRefNum: INTEGER;         {destination vol identifier}
  12031.        filler8: INTEGER;
  12032.        ioNewName: Ptr;                 {ptr to destination pathname}
  12033.        ioCopyName: Ptr;                {ptr to optional name}
  12034.        ioNewDirID: LONGINT);           {destination directory ID}
  12035.      WDParam:
  12036.        (filler9: INTEGER;
  12037.        ioWDIndex: INTEGER;
  12038.        ioWDProcID: LONGINT;
  12039.        ioWDVRefNum: INTEGER;
  12040.        filler10: INTEGER;
  12041.        filler11: LONGINT;
  12042.        filler12: LONGINT;
  12043.        filler13: LONGINT;
  12044.        ioWDDirID: LONGINT);
  12045.    END;
  12046.  
  12047. »FileParam Variant ( ParamBlockRec and HParamBlockRec)
  12048.  
  12049. The fileParam variants of ParamBlockRec and HParamBlockRec are identical, with one
  12050. exception:  The field ioDirID in HParamBlockRec is called ioFlNum in ParamBlockRec.
  12051. The fields of the fileParam variant of HParamBlockRec are as follows:  
  12052.  
  12053. •••Refer to Technical Note #204:•••
  12054.  
  12055.   fileParam:
  12056.    (ioFRefNum:     INTEGER;     {path reference number}
  12057.     ioFVersNum:    SignedByte;  {version number}
  12058.     filler1:       SignedByte;  {not used}
  12059.     ioFDirIndex:   INTEGER;     {index}
  12060.     ioFlAttrib:    SignedByte;  {file attributes}
  12061.     ioFlVersNum:   SignedByte;  {version number}
  12062.     ioFlFndrInfo:  FInfo;       {information used by the Finder}
  12063.     ioDirID:       LONGINT;     {directory ID or file number}
  12064.     ioFlStBlk:     INTEGER;     {first allocation block of data fork}
  12065.     ioFlLgLen:     LONGINT;     {logical end-of-file of data fork}
  12066.     ioFlPyLen:     LONGINT;     {physical end-of-file of data fork}
  12067.     ioFlRStBlk:    INTEGER;     {first allocation block of resource fork}
  12068.     ioFlRLgLen:    LONGINT;     {logical end-of-file of resource fork}
  12069.     ioFlRPyLen:    LONGINT;     {physical end-of-file of resource fork}
  12070.     ioFlCrDat:     LONGINT;     {date and time of creation}
  12071.     ioFlMdDat:     LONGINT);    {date and time of last modification}
  12072.  
  12073. IOFDirIndex can be used with the PBGetFInfo and PBHGetFInfo to index through the
  12074. files in a given directory.
  12075.  
  12076. Warning:  When used with GetFileInfo, ioFDirIndex will index only the files
  12077.           in a directory. To index both files and directories, you can use
  12078.           ioFDirIndex with PBGetCatInfo.
  12079.  
  12080. IOFlAttrib contains the following file attributes:
  12081.  
  12082.   Bit    Meaning
  12083.  
  12084.    0     Set if file is locked
  12085.    2     Set if resource fork is open
  12086.    3     Set if data fork is open
  12087.    4     Set if a directory
  12088.    7     Set if file (either fork) is open
  12089.  
  12090. When passed to a routine, ioDirID contains a directory ID; it can be used to refer to
  12091. a directory or, in conjuction with a partial pathname from that directory, to other
  12092. files and directories. If both a directory ID and a working directory reference
  12093. number are provided, the directory ID is used to identify the directory on the volume
  12094. indicated by the working directory reference number. In other words, a directory ID
  12095. specified by the caller will override the working directory referred to by the working
  12096. directory reference number. If you don’t want this to happen, you can set ioDirID to
  12097. 0. (If no directory is specified through a working directory reference number, the
  12098. root directory ID will be used.)
  12099.  
  12100. When returned from a routine, ioDirID contains the file number of a file; most programmers
  12101. needn’t be concerned with file numbers, but those interested can read the section
  12102. “Data Organization on Volumes”.
  12103.  
  12104. IOFlStBlk and ioFlRStBlk contain 0 if the file’s data or resource fork is empty,
  12105. respectively; they’re used only with flat volumes. The date and time in the ioFlCrDat
  12106. and ioFlMdDat fields are specified in seconds since midnight,
  12107. January 1, 1904.
  12108.  
  12109. »VolumeParam Variant (ParamBlockRec)
  12110.  
  12111. When you call GetVolInfo, you’ll use the volumeParam variant of ParamBlockRec:
  12112.  
  12113.   volumeParam:
  12114.    (filler2:      LONGINT;    {not used}
  12115.     ioVolIndex:   INTEGER;    {index}
  12116.     ioVCrDate:    LONGINT;    {date and time of initialization}
  12117.     ioVLsBkUp:    LONGINT;    {date and time of last modification}
  12118.     ioVAtrb:      INTEGER;    {volume attributes}
  12119.     ioVNmFls:     INTEGER;    {number of files in root directory}
  12120.     ioVDirSt:     INTEGER;    {first block of directory}
  12121.     ioVBlLn:      INTEGER;    {length of directory in blocks}
  12122.     ioVNmAlBlks:  INTEGER;    {number of allocation blocks}
  12123.     ioVAlBlkSiz:  LONGINT;    {size of allocation blocks}
  12124.     ioVClpSiz:    LONGINT;    {number of bytes to allocate}
  12125.     ioAlBlSt:     INTEGER;    {first block in volume block map}
  12126.     ioVNxtFNum:   LONGINT;    {next unused file number}
  12127.     ioVFrBlk:     INTEGER);   {number of unused allocation blocks}
  12128.  
  12129. IOVolIndex can be used to index through all the mounted volumes; using an index of 1
  12130. accesses the first volume mounted, and so on. (For more information on indexing, see
  12131. the section “Indexing” above.)
  12132.  
  12133. IOVLsBkUp contains the date and time the volume information was last modified
  12134. (this is not necessarily when it was flushed). (This field is not modified when
  12135. information is written to a file.)
  12136.  
  12137. Note:  The name ioVLsBkUp is actually a misnomer; this field has always
  12138.        contained the date and time of the last modification to the volume,
  12139.        not the last backup.
  12140.  
  12141. Most programmers needn’t be concerned with the remaining parameters, but interested
  12142. programmers can read the section “Data Organization on Volumes”.
  12143.  
  12144. »VolumeParam Variant (HParamBlockRec)
  12145.  
  12146. When you call HGetVInfo and SetVolInfo, you’ll use the volumeParam variant of HParamBlockRec.
  12147. This is a superset of the volumeParam variant of ParamBlockRec; the names and functions
  12148. of certain fields have been changed, and new fields have been added:
  12149.  
  12150.   volumeParam:
  12151.    (filler2:      LONGINT;    {not used}
  12152.     ioVolIndex:   INTEGER;    {index}
  12153.     ioVCrDate:    LONGINT;    {date and time of initialization}
  12154.     ioVLsMod:     LONGINT;    {date and time of last modification}
  12155.     ioVAtrb:      INTEGER;    {volume attributes}
  12156.     ioVNmFls:     INTEGER;    {number of files in root directory}
  12157.     ioVBitMap:    INTEGER;    {first block of volume bit map}
  12158.     ioAllocPtr:   INTEGER;    {block at which next new file starts}
  12159.     ioVNmAlBlks:  INTEGER;    {number of allocation blocks}
  12160.     ioVAlBlkSiz:  LONGINT;    {size of allocation blocks}
  12161.     ioVClpSiz:    LONGINT;    {number of bytes to allocate}
  12162.     ioAlBlSt:     INTEGER;    {first block in volume block map}
  12163.     ioVNxtCNID:   LONGINT;    {next unused file number}
  12164.     ioVFrBlk:     INTEGER;    {number of unused allocation blocks}
  12165.     ioVSigWord:   INTEGER;    {volume signature}
  12166.     ioVDrvInfo:   INTEGER;    {drive number}
  12167.     ioVDRefNum:   INTEGER;    {driver reference number}
  12168.     ioVFSID:      INTEGER;    {file system handling this volume}
  12169.     ioVBkUp:      LONGINT;    {date and time of last backup}
  12170.     ioVSeqNum:    INTEGER;    {used internally}
  12171.     ioVWrCnt      LONGINT;    {volume write count}
  12172.     ioVFilCnt:    LONGINT;    {number of files on volume}
  12173.     ioVDirCnt:    LONGINT;    {number of directories on volume}
  12174.     ioVFndrInfo:  ARRAY[1..8] OF LONGINT); {information used by the Finder}
  12175.  
  12176. IOVolIndex can be used to index through all the mounted volumes; using an index of 1
  12177. accesses the first volume mounted, and so on. (For more information on indexing, see
  12178. the section “Indexing” above.)
  12179.  
  12180. IOVLsMod contains the date and time the volume information was last modified
  12181. (this is not necessarily when it was flushed). (This field is not modified when
  12182. information is written to a file.)
  12183.  
  12184. Note:  IOVLsMod replaces the field ioVLsBkUp in ParamBlockRec. The name
  12185.        ioVLsBkUp was actually a misnomer; this field has always contained
  12186.        the date and time of the last modification, not the last backup.
  12187.        Another field, ioVBkUp, contains the date and time of the last backup.
  12188.  
  12189. IOVClpSiz can be used to set the volume clump size in bytes; it’s used for files that
  12190. don’t have a clump size defined as part of their file information in the catalog. To
  12191. promote file contiguity and avoid fragmentation, space is allocated to a file not in
  12192. allocation blocks but in clumps. A clump is a group of contiguous allocation blocks.
  12193. The clump size is always a multiple of the allocation block size; it’s the minimum
  12194. number of bytes to allocate each time the Allocate function is called or the end-of-file
  12195. is reached during the Write routine.
  12196.  
  12197. IOVSigWord contains a signature word identifying the type of volume; it’s $D2D7 for
  12198. flat directory volumes and $4244 for hierarchical directory volumes. The drive number
  12199. of the drive containing the volume is returned in ioDrvInfo. For on-line volumes,
  12200. ioVDRefNum returns the reference number of the I/O driver for the drive identified by
  12201. ioDrvInfo.
  12202.  
  12203. IOVFSID is the file-system identifier. It indicates which file system is servicing
  12204. the volume; it’s 0 for File Manager volumes and nonzero for volumes handled by an
  12205. external file system.
  12206.  
  12207. IOVBkUp specifies the date and time the volume was last backed up (it’s 0 if never
  12208. backed up).
  12209.  
  12210. IOVNmFls contains the number of files in the root directory. IOVFilCnt contains the
  12211. total number of files on the volume, while ioVDirCnt contains the total number of
  12212. directories (not including the root directory).
  12213.  
  12214. Most programmers needn’t be concerned with the other parameters, but interested
  12215. programmers can read the section “Data Organization on Volumes”.
  12216.  
  12217. HParamBlockRec, described above, has been extended to support a shared environment
  12218. with the addition of AccessParam, ObjParam, CopyParam, and
  12219. WDParam, as shown below.  (The complete HParamBlockRec data type is shown in the
  12220. summary.)
  12221.  
  12222.   AccessParam:
  12223.    (filler3:       INTEGER;
  12224.     ioDenyModes:   INTEGER;      {access rights data}
  12225.     filler4:       INTEGER;
  12226.     filler5:       Signed Byte;
  12227.     ioACUser:      Signed Byte;  {access rights for directory only}
  12228.     filler6:       LONGINT;
  12229.     ioACOwnerID:   LONGINT;      {owner ID}
  12230.     ioACGroupID:   LONGINT;      {group ID}
  12231.     ioACAccess:    LONGINT);     {access rights}
  12232.  
  12233.   ObjParam:
  12234.    (filler7:       INTEGER;
  12235.     ioObjType:     INTEGER;   {function code}
  12236.     ioObjNamePtr:  Ptr;       {ptr to returned creator/group name}
  12237.     ioObjID:       LONGINT;   {creator/group ID}
  12238.     ioReqCount:    LONGINT;   {size of buffer area}
  12239.     ioActCount:    LONGINT);  {length of vol parms data}
  12240.  
  12241.   CopyParam:
  12242.    (ioDstVRefNum:  INTEGER;   {destination vol identifier}
  12243.     filler8:       INTEGER;
  12244.     ioNewName:     Ptr;       {ptr to destination pathname}
  12245.     ioCopyName:    Ptr;       {ptr to optional name}
  12246.     ioNewDirID:    LONGINT);  {destination directory ID}
  12247.  
  12248.   WDParam:
  12249.    (filler9:       INTEGER;
  12250.     ioWDIndex:     INTEGER;
  12251.     ioWDProcID:    LONGINT;
  12252.     ioWDVRefNum:   INTEGER;
  12253.     filler10:      INTEGER;
  12254.     filler11:      LONGINT;
  12255.     filler12:      LONGINT;
  12256.     filler13:      LONGINT;
  12257.     ioWDDirID:     LONGINT);
  12258.  
  12259.  
  12260. æKY FCBPBPtr,FCBPBRec
  12261. æFp Files.p
  12262. æT TYPE
  12263. æC FCBPBPtr = ^FCBPBRec;
  12264. FCBPBRec = RECORD
  12265.    qLink: QElemPtr;
  12266.    qType: INTEGER;
  12267.    ioTrap: INTEGER;
  12268.    ioCmdAddr: Ptr;
  12269.    ioCompletion: ProcPtr;
  12270.    ioResult: OSErr;
  12271.    ioNamePtr: StringPtr;
  12272.    ioVRefNum: INTEGER;
  12273.    ioRefNum: INTEGER;
  12274.    filler: INTEGER;
  12275.    ioFCBIndx: INTEGER;
  12276.    filler1: INTEGER;
  12277.    ioFCBFlNm: LONGINT;
  12278.    ioFCBFlags: INTEGER;
  12279.    ioFCBStBlk: INTEGER;
  12280.    ioFCBEOF: LONGINT;
  12281.    ioFCBPLen: LONGINT;
  12282.    ioFCBCrPs: LONGINT;
  12283.    ioFCBVRefNum: INTEGER;
  12284.    ioFCBClpSiz: LONGINT;
  12285.    ioFCBParID: LONGINT;
  12286.    END;
  12287.  
  12288. æKY CInfoType,hFileInfo,dirInfo
  12289. æFp Files.p
  12290. æC CInfoType = (hFileInfo,dirInfo);
  12291.  
  12292. æKY AddDrive
  12293. æFp Files.p
  12294. æT PROCEDURE
  12295. æTN $A04E
  12296. æD PROCEDURE AddDrive(drvrRefNum: INTEGER;drvNum: INTEGER;qEl: DrvQElPtr);
  12297. æDT AddDrive(drvrRefNum,drvNum,qEl);
  12298. æRT 36, 108 
  12299. æRI AddDrive function  N36, N108-1
  12300.  
  12301.  
  12302. æKY Allocate
  12303. æFp Files.p
  12304. æT FUNCTION
  12305. æTN $A010
  12306. æD FUNCTION Allocate(refNum: INTEGER;VAR count: LONGINT): OSErr;
  12307. æDT myVariable := Allocate(refNum,count);
  12308. æRI Allocate function high-level  IV-112 low-level  IV-143
  12309. æC  
  12310. [Not in ROM]
  12311.  
  12312. Allocate adds the number of bytes specified by the count parameter to the open file
  12313. whose access path is specified by refNum, and sets the physical end-of-file to one
  12314. byte beyond the last block allocated. The number of bytes actually allocated is
  12315. rounded up to the nearest multiple of the allocation block size, and returned in the
  12316. count parameter. If there isn’t enough empty space on the volume to satisfy the
  12317. allocation request, Allocate allocates the rest of the space on the volume and returns
  12318. dskFulErr as its function result.
  12319.  
  12320. Result codes    noErr        No error
  12321.                 dskFulErr    Disk full
  12322.                 fLckdErr     File locked
  12323.                 fnOpnErr     File not open
  12324.                 ioErr        I/O error
  12325.                 rfNumErr     Bad reference number
  12326.                 vLckdErr     Software volume lock
  12327.                 wPrErr       Hardware volume lock
  12328.                 wrPermErr    Read/write permission doesn’t allow writing
  12329.  
  12330. æKY AllocContig
  12331. æFp Files.p
  12332. æT FUNCTION
  12333. æD FUNCTION AllocContig(refNum: INTEGER;VAR count: LONGINT): OSErr;
  12334. æDT myVariable := AllocContig(refNum,count);
  12335. æRT 218
  12336. æRI AllocContig function  IV-143 high-level  IV-112 low-level  IV-143
  12337.  
  12338. æKY alphaStage
  12339. æFp Files.p
  12340. æC alphaStage = $40;
  12341.  
  12342. æKY betaStage
  12343. æFp Files.p
  12344. æC betaStage = $60;
  12345.  
  12346. æKY CatMove
  12347. æFp Files.p
  12348. æT FUNCTION
  12349. æTN $A260
  12350. æD FUNCTION CatMove(vRefNum: INTEGER;dirID: LONGINT;oldName: Str255;newDirID: LONGINT;
  12351.     newName: Str255): OSErr;
  12352. æDT myVariable := CatMove(vRefNum,dirID,oldName,newDirID,newName);
  12353. æRT 218
  12354. æRI CatMove function  IV-157
  12355.  
  12356. æKY CInfoPBRec,CInfoPBPtr
  12357. æFp Files.p
  12358. æT TYPE
  12359. æC CInfoPBPtr = ^CInfoPBRec;
  12360. CInfoPBRec = RECORD
  12361.    qLink: QElemPtr;
  12362.    qType: INTEGER;
  12363.    ioTrap: INTEGER;
  12364.    ioCmdAddr: Ptr;
  12365.    ioCompletion: ProcPtr;
  12366.    ioResult: OSErr;
  12367.    ioNamePtr: StringPtr;
  12368.    ioVRefNum: INTEGER;
  12369.    ioFRefNum: INTEGER;
  12370.    ioFVersNum: SignedByte;
  12371.    filler1: SignedByte;
  12372.    ioFDirIndex: INTEGER;
  12373.    ioFlAttrib: SignedByte;
  12374.    filler2: SignedByte;
  12375.    CASE CInfoType OF
  12376.      hFileInfo:
  12377.        (ioFlFndrInfo: FInfo;
  12378.        ioDirID: LONGINT;
  12379.        ioFlStBlk: INTEGER;
  12380.        ioFlLgLen: LONGINT;
  12381.        ioFlPyLen: LONGINT;
  12382.        ioFlRStBlk: INTEGER;
  12383.        ioFlRLgLen: LONGINT;
  12384.        ioFlRPyLen: LONGINT;
  12385.        ioFlCrDat: LONGINT;
  12386.        ioFlMdDat: LONGINT;
  12387.        ioFlBkDat: LONGINT;
  12388.        ioFlXFndrInfo: FXInfo;
  12389.        ioFlParID: LONGINT;
  12390.        ioFlClpSiz: LONGINT);
  12391.      dirInfo:
  12392.        (ioDrUsrWds: DInfo;
  12393.        ioDrDirID: LONGINT;
  12394.        ioDrNmFls: INTEGER;
  12395.        filler3: ARRAY [1..9] OF INTEGER;
  12396.        ioDrCrDat: LONGINT;
  12397.        ioDrMdDat: LONGINT;
  12398.        ioDrBkDat: LONGINT;
  12399.        ioDrFndrInfo: DXInfo;
  12400.        ioDrParID: LONGINT);
  12401.    END;
  12402.  
  12403. »CInfoPBRec
  12404.  
  12405. The routines GetCatInfo and SetCatInfo are used for getting and setting information
  12406. about the files and directories within a directory. With files,
  12407. you’ll use the following 19 additional fields after the standard eight fields in the
  12408. parameter block record CInfoPBRec:
  12409.  
  12410.     ioFRefNum:      INTEGER;     {path reference number}
  12411.     ioFVersNum:     SignedByte;  {version number}
  12412.     filler1:        SignedByte;  {not used}
  12413.     ioFDirIndex:    INTEGER;     {index}
  12414.     ioFlAttrib:     SignedByte;  {file attributes}
  12415.     filler2:        SignedByte;  {not used}
  12416.   hFileInfo:
  12417.    (ioFlFndrInfo:   FInfo;       {information used by the Finder}
  12418.     ioDirID:        LONGINT;     {directory ID or file number}
  12419.     ioFlStBlk:      INTEGER;     {first allocation block of data fork}
  12420.     ioFlLgLen:      LONGINT;     {logical end-of-file of data fork}
  12421.     ioFlPyLen:      LONGINT;     {physical end-of-file of data fork}
  12422.     ioFlRStBlk:     INTEGER;     {first allocation block of resource fork}
  12423.     ioFlRLgLen:     LONGINT;     {logical end-of-file of resource fork}
  12424.     ioFlRPyLen:     LONGINT;     {physical end-of-file of resource fork}
  12425.     ioFlCrDat:      LONGINT;     {date and time of creation}
  12426.     ioFlMdDat:      LONGINT;     {date and time of last modification}
  12427.     ioFlBkDat:      LONGINT;     {date and time of last backup}
  12428.     ioFlXFndrInfo:  FXInfo;      {additional information used by the Finder}
  12429.     ioFlParID:      LONGINT;     {file's parent directory ID (integer)}
  12430.     ioFlClpSiz:     LONGINT);    {file's clump size}
  12431.  
  12432. •••Refer to Technical Note #69:•••
  12433.  
  12434. IOFDirIndex can be used with the function PBGetCatInfo to index through the files and
  12435. directories in a given directory. For each iteration of the function, you can determine
  12436. whether it’s a file or a directory by testing bit 4 (the fifth least significant bit)
  12437. of ioFlAttrib. You can test for a directory by using the Toolbox Utilities BitTst
  12438. function in the following manner (remember, the Toolbox Utilities routines reverse
  12439. the standard 68000 notation):
  12440.  
  12441.   BitTst(@myCInfoRec.ioFlAttrib,3)
  12442.  
  12443. IOFlAttrib contains the following attributes:
  12444.  
  12445.   Bit    Meaning
  12446.  
  12447.    0     Set if file is locked
  12448.    2     Set if resource fork is open
  12449.    3     Set if data fork is open
  12450.    4     Set if a directory
  12451.    7     Set if file (either fork) is open
  12452.  
  12453. When passed to a routine, ioDirID contains a directory ID; it can be used to refer to
  12454. a directory or, in conjuction with a partial pathname from that directory, to other
  12455. files and directories. If both a directory ID and a working directory reference
  12456. number are provided, the directory ID is used to identify the directory on the volume
  12457. indicated by the working directory reference number. In other words, a directory ID
  12458. specified by the caller will override the working directory referred to by the working
  12459. directory reference number. If you don’t want this to happen, you can set ioDirID to
  12460. 0. (If no directory is specified through a working directory reference number, the
  12461. root directory ID will be used.)
  12462.  
  12463. Warning:  With files, ioDirID returns the file number of the file; when
  12464.           indexing with GetCatInfo, you’ll need to reset this field for
  12465.           each iteration.
  12466.  
  12467. IOFlStBlk and ioFlRStBlk contain 0 if the file’s data or resource fork is empty,
  12468. respectively; they’re used only with flat volumes. The date and time in the ioFlCrDat,
  12469. ioFlMdDat, and ioFlBkDat fields are specified in seconds since midnight, January 1,
  12470. 1904.
  12471.  
  12472. IOFlParID contains the directory ID of the file’s parent. IOFlClpSiz is the clump
  12473. size to be used when writing the file; if it’s 0, the volume’s clump size is used
  12474. when the file is opened.
  12475.  
  12476. With directories, you’ll use the following 14 additional fields after the standard
  12477. eight fields in the parameter block record CInfoPBRec:
  12478.  
  12479.     ioFRefNum:     INTEGER;     {file reference number}
  12480.     ioFVersNum     SignedByte;  {version number}
  12481.     filler1:       SignedByte;  {not used}
  12482.     ioFDirIndex:   INTEGER;     {index}
  12483.     ioFlAttrib:    SignedByte;  {file attributes}
  12484.     filler2:       SignedByte;  {not used}
  12485.   dirInfo:
  12486.    (ioDrUsrWds:    DInfo;       {information used by the Finder}
  12487.     ioDrDirID:     LONGINT;     {directory ID}
  12488.     ioDrNmFls:     INTEGER;     {number of files in directory}
  12489.     filler3:       ARRAY[1..9] OF INTEGER; {not used}
  12490.     ioDrCrDat:     LONGINT;     {date and time of creation}
  12491.     ioDrMdDat:     LONGINT;     {date and time of last modification}
  12492.     ioDrBkDat:     LONGINT;     {date and time of last backup}
  12493.     ioDrFndrInfo:  DXInfo;      {additional information used by the Finder}
  12494.     ioDrParID:     LONGINT);    {directory's parent directory ID (integer)}
  12495.  
  12496. IOFDirIndex can be used with the function PBGetCatInfo to index through the files and
  12497. directories in a given directory. For each iteration of the function, you can determine
  12498. whether it’s a file or a directory by testing bit 4 of ioFlAttrib.
  12499.  
  12500. When passed to a routine, ioDrDirID contains a directory ID; it can be used to refer
  12501. to a directory or, in conjuction with a partial pathname from that directory, to
  12502. other files and directories. If both a directory ID and a working directory reference
  12503. number are provided, the directory ID is used to identify the directory on the volume
  12504. indicated by the working directory reference number. In other words, a directory ID
  12505. specified by the caller will override the working directory referred to by the working
  12506. directory reference number. If you don’t want this to happen, you can set ioDirID to
  12507. 0. (If no directory is specified through a working directory reference number, the
  12508. root directory ID will be used.)
  12509.  
  12510. With directories, ioDrDirID returns the directory ID of the directory.
  12511.  
  12512. IODrNmFls is the number of files and directories contained in this directory
  12513. (the valence of the directory).
  12514.  
  12515. The date and time in the ioDrCrDat, ioDrMdDat, and ioDrBkDat fields are specified in
  12516. seconds since midnight, January 1, 1904.
  12517.  
  12518. IODrParID contains the directory ID of the directory’s parent.
  12519.  
  12520. æKY CloseWD
  12521. æFp Files.p
  12522. æT FUNCTION
  12523. æTN $A260
  12524. æD FUNCTION CloseWD(wdRefNum: INTEGER): OSErr;
  12525. æDT myVariable := CloseWD(wdRefNum);
  12526. æRT 218
  12527. æRI CloseWD function  IV-158
  12528.  
  12529. æKY CMovePBRec,CMovePBPtr
  12530. æFp Files.p
  12531. æT TYPE
  12532. æC CMovePBPtr = ^CMovePBRec;
  12533. CMovePBRec = RECORD
  12534.    qLink: QElemPtr;
  12535.    qType: INTEGER;
  12536.    ioTrap: INTEGER;
  12537.    ioCmdAddr: Ptr;
  12538.    ioCompletion: ProcPtr;
  12539.    ioResult: OSErr;
  12540.    ioNamePtr: StringPtr;
  12541.    ioVRefNum: INTEGER;
  12542.    filler1: LONGINT;
  12543.    ioNewName: StringPtr;
  12544.    filler2: LONGINT;
  12545.    ioNewDirID: LONGINT;
  12546.    filler3: ARRAY [1..2] OF LONGINT;
  12547.    ioDirID: LONGINT;
  12548.    END;
  12549.  
  12550. »CMovePBRec
  12551.  
  12552. When you call CatMove to move files or directories into a different directory, you’ll
  12553. use the following six additional fields after the standard eight fields in the parameter
  12554. block record CMovePBRec:
  12555.  
  12556.   filler1:     LONGINT;    {not used}
  12557.   ioNewName:   StringPtr;  {name of new directory}
  12558.   filler2:     LONGINT;    {not used}
  12559.   ioNewDirID:  LONGINT;    {directory ID of new directory}
  12560.   filler3:     ARRAY[1..2] OF LONGINT; {not used}
  12561.   ioDirID:     LONGINT);   {directory ID of current directory}
  12562.  
  12563. IONewName and ioNewDirID specify the name and directory ID of the directory to which
  12564. the file or directory is to be moved. IODirID (used in conjuntion with the ioVRefNum
  12565. and ioNamePtr) specifies the current directory ID of the file or directory to be
  12566. moved.
  12567.  
  12568. æKY Create
  12569. æFp Files.p
  12570. æT FUNCTION
  12571. æTN $A008
  12572. æD FUNCTION Create(fileName: Str255;vRefNum: INTEGER;creator: OSType;fileType: OSType): OSErr;
  12573. æDT myVariable := Create(fileName,vRefNum,creator,fileType);
  12574. æRI Create function  high-level II-90, IV-112 low-level II-107, IV-145
  12575. æC  
  12576. [Not in ROM]
  12577.  
  12578. Create creates a new file (both forks) with the specified name, file type, and creator
  12579. on the specified volume. (File type and creator are discussed in the Finder Interface
  12580. chapter.) The new file is unlocked and empty. The date and time of its creation and
  12581. last modification are set to the current date and time.
  12582.  
  12583. Result codes    noErr        No error
  12584.                 bdNamErr     Bad file name
  12585.                 dupFNErr     Duplicate file name and version
  12586.                 dirFulErr    File directory full
  12587.                 extFSErr     External file system
  12588.                 ioErr        I/O error
  12589.                 nsvErr       No such volume
  12590.                 vLckdErr     Software volume lock
  12591.                 wPrErr       Hardware volume lock
  12592.  
  12593. æKY developStage
  12594. æFp Files.p
  12595. æC developStage = $20;
  12596.  
  12597. æKY DInfo
  12598. æFp Files.p
  12599. æT RECORD
  12600. æC DInfo = RECORD
  12601.    frRect: Rect;                       {folder rect}
  12602.    frFlags: INTEGER;                   {Flags}
  12603.    frLocation: Point;                  {folder location}
  12604.    frView: INTEGER;                    {folder view}
  12605.    END;
  12606.  
  12607. On hierarchical volumes, the following information about directories is maintained
  12608. for the Finder:
  12609.  
  12610. DInfo = RECORD
  12611.           frRect:      Rect;       {folder's rectangle}
  12612.           frFlags:     INTEGER;    {flags}
  12613.           frLocation:  Point;      {folder's location}
  12614.           frView:      INTEGER;    {folder's view}
  12615.         END;
  12616.  
  12617. DXInfo = RECORD
  12618.            frScroll:     Point;      {scroll position}
  12619.            frOpenChain:  LONGINT;    {directory ID chain of open folders}
  12620.            frUnused:     INTEGER;    {reserved}
  12621.            frComment:    INTEGER;    {comment ID}
  12622.            frPutAway:    LONGINT;    {directory ID}
  12623.          END;
  12624.  
  12625. When a file (or folder) is moved to the desktop on a hierarchical volume, it’s actually
  12626. moved to the root level of the file directory. (This permits all the desktop icons to
  12627. be enumerated by one simple scan of the root.) The fOnDesk bit of fdFlags is set.
  12628. FDPutAway (or frPutAway for directories) contains the directory ID of the folder that
  12629. originally contained the file (or folder); this allows the file (or folder) to be
  12630. returned there from the desktop.
  12631.  
  12632. æKY DirCreate
  12633. æFp Files.p
  12634. æT FUNCTION
  12635. æTN $A260
  12636. æD FUNCTION DirCreate(vRefNum: INTEGER;parentDirID: LONGINT;directoryName: Str255;
  12637.     VAR createdDirID: LONGINT): OSErr;
  12638. æDT myVariable := DirCreate(vRefNum,parentDirID,directoryName,createdDirID);
  12639. æRT 218
  12640. æRI DirCreate function  IV-146
  12641.  
  12642. æKY DXInfo
  12643. æFp Files.p
  12644. æT RECORD
  12645. æC DXInfo = RECORD
  12646.    frScroll: Point;                    {scroll position}
  12647.    frOpenChain: LONGINT;               {DirID chain of open folders}
  12648.    frUnused: INTEGER;                  {unused but reserved}
  12649.    frComment: INTEGER;                 {comment}
  12650.    frPutAway: LONGINT;                 {DirID}
  12651.    END;
  12652.  
  12653. æKY Eject
  12654. æFp Files.p
  12655. æT FUNCTION
  12656. æTN $A017
  12657. æD FUNCTION Eject(volName: StringPtr;vRefNum: INTEGER): OSErr;
  12658. æDT myVariable := Eject(volName,vRefNum);
  12659. æMM   
  12660. æRI Eject function high-level  II-90, IV-108 low-level  II-107, IV-135
  12661. æC  
  12662. [Not in ROM]
  12663.  
  12664. Eject flushes the volume specified by volName or vRefNum, places it off-line, and
  12665. then ejects the volume.
  12666.  
  12667. Result codes    noErr       No error
  12668.                 bdNamErr    Bad volume name
  12669.                 extFSErr    External file system
  12670.                 ioErr       I/O error
  12671.                 nsDrvErr    No such drive
  12672.                 nsvErr      No such volume
  12673.                 paramErr    No default volume
  12674. paramErr    No default volume
  12675.  
  12676. æKY finalStage
  12677. æFp Files.p
  12678. æC finalStage = $80;
  12679.  
  12680. æKY FInfo
  12681. æFp Files.p
  12682. æT RECORD
  12683. æC FInfo = RECORD
  12684.    fdType: OSType;                     {the type of the file}
  12685.    fdCreator: OSType;                  {file's creator}
  12686.    fdFlags: INTEGER;                   {flags ex. hasbundle,invisible,locked, etc.}
  12687.    fdLocation: Point;                  {file's location in folder}
  12688.    fdFldr: INTEGER;                    {folder containing file}
  12689.    END;
  12690.  
  12691. æKY FInitQueue
  12692. æFp Files.p
  12693. æT PROCEDURE
  12694. æTN $A016
  12695. æD PROCEDURE FInitQueue;
  12696. æDT FInitQueue;
  12697. æRI FInitQueue procedure  II-103, IV-128
  12698. æC 
  12699. Trap macro    _InitQueue
  12700.  
  12701. FInitQueue clears all queued File Manager calls except the current one.
  12702.  
  12703. æKY FlushVol
  12704. æFp Files.p
  12705. æT FUNCTION
  12706. æTN $A013
  12707. æD FUNCTION FlushVol(volName: StringPtr;vRefNum: INTEGER): OSErr;
  12708. æDT myVariable := FlushVol(volName,vRefNum);
  12709. æMM   
  12710. æRI FlushVol function P-132, 133 high-level  II-89, IV-108 low-level  II-105, IV-133
  12711. æC  
  12712. [Not in ROM]
  12713.  
  12714. On the volume specified by volName or vRefNum, FlushVol writes the contents of the
  12715. associated volume buffer and descriptive information about the volume (if they’ve
  12716. changed since the last time FlushVol was called).
  12717.  
  12718. Result codes    noErr       No error
  12719.                 bdNamErr    Bad volume name
  12720.                 extFSErr    External file system
  12721.                 ioErr       I/O error
  12722.                 nsDrvErr    No such drive
  12723.                 nsvErr      No such volume
  12724.                 paramErr    No default volume
  12725.  
  12726. æKY fOnDesk,fHasBundle,fInvisible,fTrash,fDesktop,fDisk
  12727. æFp Files.p
  12728. æC 
  12729.   { Flags in file information used by the Finder }
  12730.  
  12731.   fOnDesk       =  1;   {set if file is on desktop (hierarchical volumes only)}
  12732.   fHasBundle    =  8192;     {set if file has a bundle}
  12733.   fInvisible    =  16384;    {set if file's icon is invisible}
  12734.   fTrash        = -3;   {file is in Trash window}
  12735.   fDesktop      = -2;   {file is on desktop}
  12736.   fDisk         =  0;   {file is in disk window}
  12737.  
  12738. æKY fsAtMark,fsFromStart,fsFromLEOF,fsFromMark
  12739. æFp Files.p
  12740. æC 
  12741. IOPosMode and ioPosOffset specify the position of the mark for Read, Write, LockRng,
  12742. UnlockRng, and SetFPos calls. IOPosMode contains the positioning mode; bits 0 and 1
  12743. indicate how to position the mark, and you can use the following predefined constants
  12744. to set or test their value:
  12745.  
  12746. CONST  fsAtMark    = 0;    {at current mark}
  12747.        fsFromStart = 1;    {set mark relative to beginning of file}
  12748.        fsFromLEOF  = 2;    {set mark relative to logical end-of-file}
  12749.        fsFromMark  = 3;    {set mark relative to current mark}
  12750.  
  12751. If you specify fsAtMark, ioPosOffset is ignored and the operation begins wherever the
  12752. mark is currently positioned. If you choose to set the mark
  12753. (relative to either the beginning of the file, the logical end-of-file, or the current
  12754. mark), ioPosOffset must specify the byte offset from the chosen point
  12755. (either positive or negative) where the operation should begin.
  12756.  
  12757. Note:  Advanced programmers:  Bit 7 of ioPosMode is the newline flag; it’s
  12758.        set if read operations should terminate at a newline character. The
  12759.        ASCII code of the newline character is specified in the high-order
  12760.        byte of ioPosMode. If the newline flag is set, the data will be read
  12761.        one byte at a time until the newline character is encountered,
  12762.        ioReqCount bytes have been read, or the end-of-file is reached. If
  12763.        the newline flag is clear, the data will be read one byte at a time
  12764.        until ioReqCount bytes have been read or the end-of-file is reached.
  12765.  
  12766. æKY FSClose
  12767. æFp Files.p
  12768. æT FUNCTION
  12769. æD FUNCTION FSClose(refNum: INTEGER): OSErr;
  12770. æDT myVariable := FSClose(refNum);
  12771. æRT 102
  12772. æRI FSClose function  II-94, IV-112, P-132, 133, 171
  12773. æC  
  12774. [Not in ROM]
  12775.  
  12776. FSClose removes the access path specified by refNum, writes the contents of the
  12777. volume buffer to the volume, and updates the file’s entry in the file directory.
  12778.  
  12779. Note:  There’s no guarantee that any bytes have been written until
  12780.        FlushVol is called.
  12781.  
  12782. Result codes    noErr       No error
  12783.                 extFSErr    External file system
  12784.                 fnfErr      File not found
  12785.                 fnOpnErr    File not open
  12786.                 ioErr       I/O error
  12787.                 nsvErr      No such volume
  12788.                 rfNumErr    Bad reference number
  12789.  
  12790. æKY fsCurPerm,fsRdPerm,fsWrPerm,fsRdWrPerm,fsRdWrShPerm
  12791. æFp Files.p
  12792. æC 
  12793. IOPermssn requests permission to read or write via an access path, and must contain
  12794. one of the following values:
  12795.  
  12796. CONST  fsCurPerm     = 0;    {whatever is currently allowed}
  12797.        fsRdPerm      = 1;    {request for read permission only}
  12798.        fsWrPerm      = 2;    {request for write permission}
  12799.        fsRdWrPerm    = 3;    {request for exclusive read/write permission}
  12800.        fsRdWrShPerm  = 4;    {request for shared read/write permission}
  12801.  
  12802. This request is compared with the open permission of the file. If the open permission
  12803. doesn’t allow I/O as requested, a result code indicating the error is returned.
  12804.  
  12805. Warning:  To ensure data integrity be sure to lock the portion of the
  12806.           file you’ll be using if you specify shared write permission.
  12807.  
  12808. æKY FSDelete
  12809. æFp Files.p
  12810. æT FUNCTION
  12811. æD FUNCTION FSDelete(fileName: Str255;vRefNum: INTEGER): OSErr;
  12812. æDT myVariable := FSDelete(fileName,vRefNum);
  12813. æRI FSDelete function  II-97, IV-113
  12814. æC 
  12815. [Not in ROM]
  12816.  
  12817. FSDelete removes the closed file having the name fileName from the specified volume.
  12818.  
  12819. Note:  This function will delete both forks of a file.
  12820.  
  12821. Result codes    noErr       No error
  12822.                 bdNamErr    Bad file name
  12823.                 extFSErr    External file system
  12824.                 fBsyErr     File busy
  12825.                 fLckdErr    File locked
  12826.                 fnfErr      File not found
  12827.                 ioErr       I/O error
  12828.                 nsvErr      No such volume
  12829.                 vLckdErr    Software volume lock
  12830.                 wPrErr      Hardware volume lock
  12831.  
  12832. æKY FSOpen
  12833. æFp Files.p
  12834. æT FUNCTION
  12835. æD FUNCTION FSOpen(fileName: Str255;vRefNum: INTEGER;VAR refNum: INTEGER): OSErr;
  12836. æDT myVariable := FSOpen(fileName,vRefNum,refNum);
  12837. æRT 102
  12838. æRI FSOpen function  II-91, IV-109, P-131, 171
  12839. æC  
  12840. [Not in ROM]
  12841.  
  12842. FSOpen creates an access path to the file having the name fileName on the volume
  12843. specified by vRefNum. A path reference number is returned in refNum. The access
  12844. path’s read/write permission is set to whatever the file’s open permission allows.
  12845.  
  12846. Note:  There’s no guarantee that any bytes have been written until
  12847.        FlushVol is called.
  12848.  
  12849. Result codes    noErr       No error
  12850.                 bdNamErr    Bad file name
  12851.                 extFSErr    External file system
  12852.                 fnfErr      File not found
  12853.                 ioErr       I/O error
  12854.                 nsvErr      No such volume
  12855.                 opWrErr     File already open for writing
  12856.                 tmfoErr     Too many files open
  12857.  
  12858. æKY FSOpenFile
  12859. æFp Files.p
  12860. æT FUNCTION
  12861. æD FUNCTION FSOpenFile(vRefNum: INTEGER;fileName: Str255;permission: SignedByte;
  12862.     VAR refNum: INTEGER): OSErr;
  12863. æDT myVariable := FSOpenFile(vRefNum,fileName,permission,refNum);
  12864. æRT 102
  12865. æRI FSOpen function   IV-109
  12866.  
  12867. æKY FSRead
  12868. æFp Files.p
  12869. æT FUNCTION
  12870. æD FUNCTION FSRead(refNum: INTEGER;VAR count: LONGINT;buffPtr: Ptr): OSErr;
  12871. æDT myVariable := FSRead(refNum,count,buffPtr);
  12872. æRI FSRead function IV-109, P-131, 171
  12873. æC  
  12874. [Not in ROM]
  12875.  
  12876. FSRead attempts to read the number of bytes specified by the count parameter from the
  12877. open file whose access path is specified by refNum, and transfer them to the data
  12878. buffer pointed to by buffPtr. The read operation begins at the current mark, so you
  12879. might want to precede this with a call to SetFPos. If you try to read past the logical
  12880. end-of-file, FSRead moves the mark to the end-of-file and returns eofErr as its
  12881. function result. After the read is completed, the number of bytes actually read is
  12882. returned in the count parameter.
  12883.  
  12884. Result codes    noErr       No error
  12885.                 eofErr      End-of-file
  12886.                 extFSErr    External file system
  12887.                 fnOpnErr    File not open
  12888.                 ioErr       I/O error
  12889.                 paramErr    Negative count
  12890.                 rfNumErr    Bad reference number
  12891.  
  12892. æKY fsRtDirID
  12893. æFp Files.p
  12894. æC fsRtDirID = 2;
  12895.  
  12896. æKY fsRtParID
  12897. æFp Files.p
  12898. æC fsRtParID = 1;
  12899.  
  12900. æKY FSWrite
  12901. æFp Files.p
  12902. æT FUNCTION
  12903. æD FUNCTION FSWrite(refNum: INTEGER;VAR count: LONGINT;buffPtr: Ptr): OSErr;
  12904. æDT myVariable := FSWrite(refNum,count,buffPtr);
  12905. æRI FSWrite function IV-110, P-132, 171
  12906. æC  
  12907. [Not in ROM]
  12908.  
  12909. FSWrite takes the number of bytes specified by the count parameter from the buffer
  12910. pointed to by buffPtr and attempts to write them to the open file whose access path
  12911. is specified by refNum. The write operation begins at the current mark, so you might
  12912. want to precede this with a call to SetFPos. After the write is completed, the number
  12913. of bytes actually written is returned in the count parameter.
  12914.  
  12915. Result codes    noErr        No error
  12916.                 dskFulErr    Disk full
  12917.                 fLckdErr     File locked
  12918.                 fnOpnErr     File not open
  12919.                 ioErr        I/O error
  12920.                 paramErr     Negative count
  12921.                 rfNumErr     Bad reference number
  12922.                 vLckdErr     Software volume lock
  12923.                 wPrErr       Hardware volume lock
  12924.                 wrPermErr    Read/write permission doesn’t allow writing
  12925.  
  12926. æKY FXInfo
  12927. æFp Files.p
  12928. æT RECORD
  12929. æC FXInfo = RECORD
  12930.    fdIconID: INTEGER;                  {Icon ID}
  12931.    fdUnused: ARRAY [1..4] OF INTEGER;  {unused but reserved 8 bytes}
  12932.    fdComment: INTEGER;                 {Comment ID}
  12933.    fdPutAway: LONGINT;                 {Home Dir ID}
  12934.    END;
  12935.  
  12936. On hierarchical volumes, in addition to the FInfo record, the following information
  12937. about files is maintained for the Finder:
  12938.  
  12939. æKY GetDrvQHdr
  12940. æFp Files.p
  12941. æT FUNCTION
  12942. æD FUNCTION GetDrvQHdr: QHdrPtr;
  12943. æDT myVariable := GetDrvQHdr;
  12944. æRI GetDrvQHdr function  II-128, IV-181
  12945. æC 
  12946. You can get a pointer to the header of the drive queue by calling the File Manager
  12947. function GetDrvQHdr.
  12948.  
  12949. FUNCTION GetDrvQHdr :  QHdrPtr; [Not in ROM]
  12950.  
  12951. GetDrvQHdr returns a pointer to the header of the drive queue.
  12952.  
  12953. Assembly-language note:  The global variable DrvQHdr contains the
  12954.                          header of the drive queue.
  12955.  
  12956. The drive queue can support any number of drives, limited only by memory space.
  12957.  
  12958. æKY GetEOF
  12959. æFp Files.p
  12960. æT FUNCTION
  12961. æTN $A011
  12962. æD FUNCTION GetEOF(refNum: INTEGER;VAR logEOF: LONGINT): OSErr;
  12963. æDT myVariable := GetEOF(refNum,logEOF);
  12964. æRI GetEOF function P-132, 172  high-level  II-93, IV-111 low-level  II-112, IV-142
  12965. æC  
  12966. [Not in ROM]
  12967.  
  12968. GetEOF returns, in logEOF, the logical end-of-file of the open file whose access path
  12969. is specified by refNum.
  12970.  
  12971. Result codes    noErr       No error
  12972.                 extFSErr    External file system
  12973.                 fnOpnErr    File not open
  12974.                 ioErr       I/O error
  12975.                 rfNumErr    Bad reference number
  12976.  
  12977. æKY GetFInfo
  12978. æFp Files.p
  12979. æT FUNCTION
  12980. æD FUNCTION GetFInfo(fileName: Str255;vRefNum: INTEGER;VAR fndrInfo: FInfo): OSErr;
  12981. æDT myVariable := GetFInfo(fileName,vRefNum,fndrInfo);
  12982. æRI GetFInfo function  II-95, IV-113
  12983. æC  
  12984. [Not in ROM]
  12985.  
  12986. For the file having the name fileName on the specified volume, GetFInfo returns
  12987. information used by the Finder in fndrInfo (see the section “Information Used by the
  12988. Finder”).
  12989.  
  12990. Result codes    noErr       No error
  12991.                 bdNamErr    Bad file name
  12992.                 extFSErr    External file system
  12993.                 fnfErr      File not found
  12994.                 ioErr       I/O error
  12995.                 nsvErr      No such volume
  12996.                 paramErr    No default volume
  12997.  
  12998. æKY GetFPos
  12999. æFp Files.p
  13000. æT FUNCTION
  13001. æTN $A018
  13002. æD FUNCTION GetFPos(refNum: INTEGER;VAR filePos: LONGINT): OSErr;
  13003. æDT myVariable := GetFPos(refNum,filePos);
  13004. æRI GetFPos function P-132 high-level  II-92, IV-110  low-level  II-111, IV-141
  13005. æC  
  13006. [Not in ROM]
  13007.  
  13008. GetFPos returns, in filePos, the mark of the open file whose access path is specified
  13009. by refNum.
  13010.  
  13011. Result codes    noErr        No error
  13012.                 extFSErr     External file system
  13013.                 fnOpnErr     File not open
  13014.                 ioErr        I/O error
  13015.                 rfNumErr     Bad reference number
  13016.  
  13017. æKY GetFSQHdr
  13018. æFp Files.p
  13019. æT FUNCTION
  13020. æD FUNCTION GetFSQHdr: QHdrPtr;
  13021. æDT myVariable := GetFSQHdr;
  13022. æRI GetFSQHdr function  II-125, IV-175
  13023. æC 
  13024. You can get a pointer to the header of the file I/O queue by calling the File Manager
  13025. function GetFSQHdr.
  13026.  
  13027. FUNCTION GetFSQHdr :  QHdrPtr; [Not in ROM]
  13028.  
  13029. GetFSQHdr returns a pointer to the header of the file I/O queue.
  13030.  
  13031. Assembly-language note:  The global variable FSQHdr contains the
  13032.                          header of the file I/O queue.
  13033.  
  13034. æKY GetVCBQHdr
  13035. æFp Files.p
  13036. æT FUNCTION
  13037. æD FUNCTION GetVCBQHdr: QHdrPtr;
  13038. æDT myVariable := GetVCBQHdr;
  13039. æRI GetVCBQHdr function  II-126, IV-178
  13040. æC 
  13041. You can get a pointer to the header of the volume-control-block queue by calling the
  13042. File Manager function GetVCBQHdr.
  13043.  
  13044. FUNCTION GetVCBQHdr :  QHdrPtr; [Not in ROM]
  13045.  
  13046. GetVCBQHdr returns a pointer to the header of the volume-control-block queue.
  13047.  
  13048. Assembly-language note:  The global variable VCBQHdr contains the header
  13049.                          of the volume-control-block-queue. The default
  13050.                          volume’s volume control block is pointed to by
  13051.                          the global variable DefVCBPtr.
  13052.  
  13053. æKY GetVInfo
  13054. æFp Files.p
  13055. æT FUNCTION
  13056. æD FUNCTION GetVInfo(drvNum: INTEGER;volName: StringPtr;VAR vRefNum: INTEGER;
  13057.     VAR freeBytes: LONGINT): OSErr;
  13058. æDT myVariable := GetVInfo(drvNum,volName,vRefNum,freeBytes);
  13059. æRT 157
  13060. æRI GetVInfo function  II-89, IV-107, N157, low-level  II-104, IV-129
  13061. æC 
  13062. »Accessing Volumes
  13063.  
  13064. •••Refer to Technical Note #24:•••
  13065.  
  13066. FUNCTION GetVInfo (drvNum:  INTEGER; volName:  StringPtr; VAR vRefNum:  INTEGER;
  13067.                    VAR freeBytes:  LONGINT) :  OSErr; [Not in ROM]
  13068.  
  13069. •••Refer to Technical Note #157:•••
  13070.  
  13071. GetVInfo returns the name, reference number, and available space (in bytes), in
  13072. volName, vRefNum, and freeBytes, for the volume in the drive specified by drvNum.
  13073.  
  13074. Result codes    noErr       No error
  13075.                 nsvErr      No default volume
  13076.                 paramErr    Bad drive number
  13077.  
  13078. æKY GetVol
  13079. æFp Files.p
  13080. æT FUNCTION
  13081. æTN $A014
  13082. æD FUNCTION GetVol(volName: StringPtr;VAR vRefNum: INTEGER): OSErr;
  13083. æDT myVariable := GetVol(volName,vRefNum);
  13084. æRT 77,140
  13085. æRI GetVol function N77-2, N140 high-level  II-89, IV-107  low-level  II-104, IV-131
  13086. æC  
  13087. [Not in ROM]
  13088.  
  13089. GetVol returns the name of the default volume in volName and its volume reference
  13090. number in vRefNum.
  13091.  
  13092. Result codes    noErr     No error
  13093.                 nsvErr    No such volume
  13094.  
  13095. æKY GetVRefNum
  13096. æFp Files.p
  13097. æT FUNCTION
  13098. æD FUNCTION GetVRefNum(fileRefNum: INTEGER;VAR vRefNum: INTEGER): OSErr;
  13099. æDT myVariable := GetVRefNum(fileRefNum,vRefNum);
  13100. æRI GetVRefNum function  II-89, IV-107
  13101. æC  
  13102. [Not in ROM]
  13103.  
  13104. Given a path reference number in pathRefNum, GetVRefNum returns the volume reference
  13105. number in vRefNum.
  13106.  
  13107. Result codes    noErr       No error
  13108.                 rfNumErr    Bad reference number
  13109.  
  13110. æKY GetWDInfo
  13111. æFp Files.p
  13112. æT FUNCTION
  13113. æTN $A260
  13114. æD FUNCTION GetWDInfo(wdRefNum: INTEGER;VAR vRefNum: INTEGER;VAR dirID: LONGINT;
  13115.     VAR procID: LONGINT): OSErr;
  13116. æDT myVariable := GetWDInfo(wdRefNum,vRefNum,dirID,procID);
  13117. æRT 218
  13118. æRI GetWDInfo function  IV-159
  13119.  
  13120. æKY HCreate
  13121. æFp Files.p
  13122. æT FUNCTION
  13123. æD FUNCTION HCreate(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255;creator: OSType;
  13124.     fileType: OSType): OSErr;
  13125. æDT myVariable := HCreate(vRefNum,dirID,fileName,creator,fileType);
  13126. æRT 218
  13127. æRI HCreate function  IV-146
  13128.  
  13129. æKY HDelete
  13130. æFp Files.p
  13131. æT FUNCTION
  13132. æD FUNCTION HDelete(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255): OSErr;
  13133. æDT myVariable := HDelete(vRefNum,dirID,fileName);
  13134. æRI HDelete function  IV-147
  13135.  
  13136. æKY HGetFInfo
  13137. æFp Files.p
  13138. æT FUNCTION
  13139. æD FUNCTION HGetFInfo(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255;
  13140.     VAR fndrInfo: FInfo): OSErr;
  13141. æDT myVariable := HGetFInfo(vRefNum,dirID,fileName,fndrInfo);
  13142. æRI HGetFileInfo function  IV-149
  13143.  
  13144. æKY HGetVol
  13145. æFp Files.p
  13146. æT FUNCTION
  13147. æD FUNCTION HGetVol(volName: StringPtr;VAR vRefNum: INTEGER;VAR dirID: LONGINT): OSErr;
  13148. æDT myVariable := HGetVol(volName,vRefNum,dirID);
  13149. æRI HGetVol function  IV-132
  13150.  
  13151. æKY HOpen
  13152. æFp Files.p
  13153. æT FUNCTION
  13154. æD FUNCTION HOpen(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255;permission: SignedByte;
  13155.     VAR refNum: INTEGER): OSErr;
  13156. æDT myVariable := HOpen(vRefNum,dirID,fileName,permission,refNum);
  13157. æRI HOpen function  IV-136
  13158.  
  13159. æKY HOpenFile
  13160. æFp Files.p
  13161. æT FUNCTION
  13162. æD FUNCTION HOpenFile(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255;
  13163.     permission: SignedByte;VAR refNum: INTEGER): OSErr;
  13164. æDT myVariable := HOpenFile(vRefNum,dirID,fileName,permission,refNum);
  13165.  
  13166. æKY HOpenRF
  13167. æFp Files.p
  13168. æT FUNCTION
  13169. æD FUNCTION HOpenRF(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255;permission: SignedByte;
  13170.     VAR refNum: INTEGER): OSErr;
  13171. æDT myVariable := HOpenRF(vRefNum,dirID,fileName,permission,refNum);
  13172. æRI HOpenRF function  IV-137
  13173.  
  13174. æKY HRename
  13175. æFp Files.p
  13176. æT FUNCTION
  13177. æD FUNCTION HRename(vRefNum: INTEGER;dirID: LONGINT;oldName: Str255;newName: Str255): OSErr;
  13178. æDT myVariable := HRename(vRefNum,dirID,oldName,newName);
  13179. æRI HRename function IV-154
  13180.  
  13181. æKY HRstFLock
  13182. æFp Files.p
  13183. æT FUNCTION
  13184. æD FUNCTION HRstFLock(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255): OSErr;
  13185. æDT myVariable := HRstFLock(vRefNum,dirID,fileName);
  13186. æRI HRstFLock function  IV-152
  13187.  
  13188. æKY HSetFInfo
  13189. æFp Files.p
  13190. æT FUNCTION
  13191. æD FUNCTION HSetFInfo(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255;
  13192.     fndrInfo: FInfo): OSErr;
  13193. æDT myVariable := HSetFInfo(vRefNum,dirID,fileName,fndrInfo);
  13194. æRI HSetFileInfo function  IV-150
  13195.  
  13196. æKY HSetFLock
  13197. æFp Files.p
  13198. æT FUNCTION
  13199. æD FUNCTION HSetFLock(vRefNum: INTEGER;dirID: LONGINT;fileName: Str255): OSErr;
  13200. æDT myVariable := HSetFLock(vRefNum,dirID,fileName);
  13201. æRI HSetFLock function  IV-151
  13202.  
  13203. æKY HSetVol
  13204. æFp Files.p
  13205. æT FUNCTION
  13206. æD FUNCTION HSetVol(volName: StringPtr;vRefNum: INTEGER;dirID: LONGINT): OSErr;
  13207. æDT myVariable := HSetVol(volName,vRefNum,dirID);
  13208. æRI HSetVol function  IV-133
  13209.  
  13210. æKY ioDirFlg
  13211. æFp Files.p
  13212. æC ioDirFlg = 3;
  13213.  
  13214. æKY ioDirMask
  13215. æFp Files.p
  13216. æC ioDirMask = $10;
  13217.  
  13218. æKY NumVersion
  13219. æFp Files.p
  13220. æT PACKED RECORD
  13221. æC NumVersion = PACKED RECORD
  13222.    CASE INTEGER OF
  13223.      0:
  13224.        (majorRev: SignedByte;          {1st part of version number in BCD}
  13225.        minorRev: 0..9;                 {2nd part is 1 nibble in BCD}
  13226.        bugFixRev: 0..9;                {3rd part is 1 nibble in BCD}
  13227.        stage: SignedByte;              {stage code: dev, alpha, beta, final}
  13228.        nonRelRev: SignedByte);         {revision level of non-released version}
  13229.      1:
  13230.        (version: LONGINT);             {to use all 4 fields at one time}
  13231.    END;
  13232.  
  13233. æKY OpenRF
  13234. æFp Files.p
  13235. æT FUNCTION
  13236. æTN $A00A
  13237. æD FUNCTION OpenRF(fileName: Str255;vRefNum: INTEGER;VAR refNum: INTEGER): OSErr;
  13238. æDT myVariable := OpenRF(fileName,vRefNum,refNum);
  13239. æRT 74
  13240. æRI OpenRF function  N74-1  high-level II-91, IV-109 low-level II-109, IV-137
  13241. æC  
  13242. [Not in ROM]
  13243.  
  13244. OpenRF is similar to FSOpen; the only difference is that OpenRF opens the resource
  13245. fork of the specified file rather than the data fork. A path reference number is
  13246. returned in refNum. The access path’s read/write permission is set to whatever the
  13247. file’s open permission allows.
  13248.  
  13249. Note:  Normally you should access a file’s resource fork through the
  13250.        routines of the Resource Manager rather than the File Manager.
  13251.        OpenRF doesn’t read the resource map into memory; it’s really
  13252.        only useful for block-level operations such as copying files.
  13253.  
  13254. Result codes    noErr       No error
  13255.                 bdNamErr    Bad file name
  13256.                 extFSErr    External file system
  13257.                 fnfErr      File not found
  13258.                 ioErr       I/O error
  13259.                 nsvErr      No such volume
  13260.                 opWrErr     File already open for writing
  13261.                 tmfoErr     Too many files open
  13262.  
  13263. æKY OpenWD
  13264. æFp Files.p
  13265. æT FUNCTION
  13266. æTN $A260
  13267. æD FUNCTION OpenWD(vRefNum: INTEGER;dirID: LONGINT;procID: LONGINT;VAR wdRefNum: INTEGER): OSErr;
  13268. æDT myVariable := OpenWD(vRefNum,dirID,procID,wdRefNum);
  13269. æRT 218
  13270. æRI OpenWD function  IV-158
  13271.  
  13272. æKY PBAllocate
  13273. æFp Files.p
  13274. æT FUNCTION
  13275. æTN $A010
  13276. æD FUNCTION PBAllocate(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13277. æDT myVariable := PBAllocate(paramBlock,async);
  13278. æRI PBAllocate function II-113, IV-143
  13279. æC 
  13280. Trap macro    _Allocate
  13281.  
  13282. Parameter block
  13283.   -->    12    ioCompletion  pointer
  13284.   <--    16    ioResult      word
  13285.   -->    24    ioRefNum      word
  13286.   -->    36    ioReqCount    long word
  13287.   <--    40    ioActCount    long word
  13288.  
  13289. PBAllocate adds ioReqCount bytes to the open file whose access path is specified by
  13290. ioRefNum, and sets the physical end-of-file to one byte beyond the last block allocated.
  13291. The number of bytes actually allocated is rounded up to the nearest multiple of the
  13292. allocation block size, and returned in ioActCount. If there isn’t enough empty space
  13293. on the volume to satisfy the allocation request, PBAllocate allocates the rest of the
  13294. space on the volume and returns dskFulErr as its function result.
  13295.  
  13296. Note:  Even if the total number of requested bytes is unavailable,
  13297.        PBAllocate will allocate whatever space, contiguous or not, is
  13298.        available. To force the allocation of the entire requested space
  13299.        as a contiguous piece, call PBAllocContig instead.
  13300.  
  13301. Result codes    noErr      No error
  13302.                 dskFulErr  Disk full
  13303.                 fLckdErr   File locked
  13304.                 fnOpnErr   File not open
  13305.                 ioErr      I/O error
  13306.                 rfNumErr   Bad reference number
  13307.                 vLckdErr   Software volume lock
  13308.                 wPrErr     Hardware volume lock
  13309.                 wrPermErr  Read/write permission doesn’t allow writing
  13310.  
  13311. æKY PBAllocContig
  13312. æFp Files.p
  13313. æT FUNCTION
  13314. æD FUNCTION PBAllocContig(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13315. æDT myVariable := PBAllocContig(paramBlock,async);
  13316. æRI PBAllocContig function  IV-143
  13317. æC 
  13318. Trap macro    _AllocContig
  13319.  
  13320. Parameter block
  13321.   -->    12    ioCompletion  pointer
  13322.   <--    16    ioResult      word
  13323.   -->    24    ioRefNum      word
  13324.   -->    36    ioReqCount    long word
  13325.   <--    40    ioActCount    long word
  13326.  
  13327. PBAllocContig is identical to PBAllocate except that if there isn’t enough contiguous
  13328. empty space on the volume to satisfy the allocation request, PBAllocContig will do
  13329. nothing and will return dskFulErr as its function result. If you want to allocate
  13330. whatever space is available, even when the entire request cannot be filled as a
  13331. contiguous piece, call PBAllocate instead.
  13332.  
  13333. Result codes    noErr      No error
  13334.                 dskFulErr  Disk full
  13335.                 fLckdErr   File locked
  13336.                 fnOpnErr   File not open
  13337.                 ioErr      I/O error
  13338.                 rfNumErr   Bad reference number
  13339.                 vLckdErr   Software volume lock
  13340.                 wPrErr     Hardware volume lock
  13341.                 wrPermErr  Read/write permission doesn’t allow writing
  13342.  
  13343. æKY PBCatMove
  13344. æFp Files.p
  13345. æT FUNCTION
  13346. æD FUNCTION PBCatMove(paramBlock: CMovePBPtr;async: BOOLEAN): OSErr;
  13347. æDT myVariable := PBCatMove(paramBlock,async);
  13348. æRI PBCatMove function  IV-157
  13349. æC 
  13350. •••Refer to Technical Note #226:•••
  13351.  
  13352. Trap macro    _CatMove
  13353.  
  13354. Parameter block
  13355.   -->    12    ioCompletion  pointer
  13356.   <--    16    ioResult      word
  13357.   -->    18    ioNamePtr     pointer
  13358.   -->    22    ioVRefNum     word
  13359.   -->    28    ioNewName     pointer
  13360.   -->    36    ioNewDirID    long word
  13361.   -->    48    ioDirID       long word
  13362.  
  13363. PBCatMove moves files or directories from one directory to another. The name of the
  13364. file or directory to be moved is pointed to by ioNamePtr; ioVRefNum contains either
  13365. the volume reference number or working directory reference number. A directory ID can
  13366. be specified in ioDirID. The name and directory ID of the directory to which the file
  13367. or directory is to be moved are specified by ioNewName and ioNewDirID.
  13368.  
  13369. PBCatMove is strictly a file catalog operation; it does not actually change the
  13370. location of the file or directory on the disk. PBCatMove cannot move a file or directory
  13371. to another volume (that is, ioVRefNum is used in specifying both the source and the
  13372. destination). It also cannot be used to rename files or directories; for that, use
  13373. PBHRename.
  13374.  
  13375. Result codes    noErr      No error
  13376.                 badMovErr  Attempt to move into offspring
  13377.                 bdNamErr   Bad file name or attempt to move into a file
  13378.                 dupFNErr   Duplicate file name and version
  13379.                 fnfErr     File not found
  13380.                 ioErr      I/O error
  13381.                 nsvErr     No such volume
  13382.                 paramErr   No default volume
  13383.                 vLckdErr   Software volume lock
  13384.                 wPrErr     Hardware volume lock
  13385.  
  13386. æKY PBClose
  13387. æFp Files.p
  13388. æT FUNCTION
  13389. æTN $A001
  13390. æD FUNCTION PBClose(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13391. æDT myVariable := PBClose(paramBlock,async);
  13392. æRI PBClose function IV-144  Device Manager II-184  File Manager II-114
  13393. æC 
  13394. Trap macro     _Close
  13395.  
  13396. Parameter block
  13397.   -->    12    ioCompletion  pointer
  13398.   <--    16    ioResult      word
  13399.   -->    24    ioRefNum      word
  13400.  
  13401. PBClose writes the contents of the access path buffer specified by ioRefNum to the
  13402. volume and removes the access path.
  13403.  
  13404. Warning:  Some information stored on the volume won’t be correct
  13405.           until PBFlushVol is called.
  13406.  
  13407. Result codes    noErr     No error
  13408.                 extFSErr  External file system
  13409.                 fnfErr    File not found
  13410.                 fnOpnErr  File not open
  13411.                 ioErr     I/O error
  13412.                 nsvErr    No such volume
  13413.                 rfNumErr  Bad reference number
  13414.  
  13415. æKY PBCloseWD
  13416. æFp Files.p
  13417. æT FUNCTION
  13418. æD FUNCTION PBCloseWD(paramBlock: WDPBPtr;async: BOOLEAN): OSErr;
  13419. æDT myVariable := PBCloseWD(paramBlock,async);
  13420. æRI PBCloseWD function  IV-158      
  13421. æC 
  13422. Trap macro    _CloseWD
  13423.  
  13424. Parameter block
  13425.   -->    12    ioCompletion  pointer
  13426.   <--    16    ioResult      word
  13427.   -->    22    ioVRefNum     word
  13428.  
  13429. PBCloseWD releases the working directory whose working directory reference number is
  13430. specified in ioVRefNum.
  13431.  
  13432. Note:  If a volume reference number is specified in ioVRefNum, PBCloseWD
  13433.        does nothing.
  13434.  
  13435. Result codes    noErr     No error
  13436.                 nsvErr    No such volume
  13437.  
  13438. æKY PBCreate
  13439. æFp Files.p
  13440. æT FUNCTION
  13441. æTN $A008
  13442. æD FUNCTION PBCreate(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13443. æDT myVariable := PBCreate(paramBlock,async);
  13444. æRI PBCreate function II-107, IV-145
  13445. æC 
  13446. Trap macro    _Create
  13447.  
  13448. Parameter block
  13449.   -->    12    ioCompletion  pointer
  13450.   <--    16    ioResult      word
  13451.   -->    18    ioNamePtr     pointer
  13452.   -->    22    ioVRefNum     word
  13453.   -->    26    ioFVersNum    byte
  13454.  
  13455. PBCreate creates a new file (both forks) having the name pointed to by ioNamePtr (and
  13456. on flat volumes, the version number ioVersNum) on the volume specified by ioVRefNum.
  13457. The new file is unlocked and empty. The date and time of its creation and last modification
  13458. are set to the current date and time. If the file created isn’t temporary (that is,
  13459. if it will exist after the application terminates), the application should call
  13460. PBSetFInfo (after PBCreate) to fill in the information needed by the Finder.
  13461.  
  13462. Assembly-language note:  If a desk accessory creates a file, it should
  13463.                          always create it in the directory containing the
  13464.                          system folder. The working directory reference
  13465.                          number for this directory is stored in the global
  13466.                          variable BootDrive; you can pass it in ioVRefNum.
  13467.  
  13468. Result codes    noErr      No error
  13469.                 bdNamErr   Bad file name
  13470.                 dupFNErr   Duplicate file name and version
  13471.                 dirFulErr  File directory full
  13472.                 extFSErr   External file system
  13473.                 ioErr      I/O error
  13474.                 nsvErr     No such volume
  13475.                 vLckdErr   Software volume lock
  13476.                 wPrErr     Hardware volume lock
  13477.  
  13478. æKY PBDelete
  13479. æFp Files.p
  13480. æT FUNCTION
  13481. æTN $A009
  13482. æD FUNCTION PBDelete(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13483. æDT myVariable := PBDelete(paramBlock,async);
  13484. æRI PBDelete function II-119, IV-147
  13485. æC 
  13486. Trap macro    _Delete
  13487.  
  13488. Parameter block
  13489.   -->    12    ioCompletion  pointer
  13490.   <--    16    ioResult      word
  13491.   -->    18    ioNamePtr     pointer
  13492.   -->    22    ioVRefNum     word
  13493.   -->    26    ioFVersNum    byte
  13494.  
  13495. PBDelete removes the closed file having the name pointed to by ioNamePtr (and on flat
  13496. volumes, the version number ioVersNum) from the volume pointed to by ioVRefNum.
  13497. PBHDelete can be used to delete an empty directory as well.
  13498.  
  13499. Note:  This function will delete both forks of the file.
  13500.  
  13501. Result codes    noErr     No error
  13502.                 bdNamErr  Bad file name
  13503.                 extFSErr  External file system
  13504.                 fBsyErr   File busy, directory not empty, or working
  13505.                           directory control block open
  13506.                 fLckdErr  File locked
  13507.                 fnfErr    File not found
  13508.                 nsvErr    No such volume
  13509.                 ioErr     I/O error
  13510.                 vLckdErr  Software volume lock
  13511.                 wPrErr    Hardware volume lock
  13512.  
  13513. æKY PBDirCreate
  13514. æFp Files.p
  13515. æT FUNCTION
  13516. æD FUNCTION PBDirCreate(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  13517. æDT myVariable := PBDirCreate(paramBlock,async);
  13518. æRI PBDirCreate function  IV-146
  13519. æC 
  13520. Trap macro    _DirCreate
  13521.  
  13522. Parameter block
  13523.   -->    12    ioCompletion  pointer
  13524.   <--    16    ioResult      word
  13525.   <->    18    ioNamePtr     pointer
  13526.   -->    22    ioVRefNum     word
  13527.   <->    48    ioDirID       long word
  13528.  
  13529. PBDirCreate is identical to PBHCreate except that it creates a new directory instead
  13530. of a file. You can specify the parent of the directory to be created in ioDirID; if
  13531. it’s 0, the new directory will be placed in the root directory. The directory ID of
  13532. the new directory is returned in ioDirID.
  13533.  
  13534. Warning:  PBDirCreate operates only with the hierarchical version of
  13535.           the File Manager; if used on a Macintosh equipped only with
  13536.           the 64K ROM version of the File Manager, it will generate a
  13537.           system error.
  13538.  
  13539. Result codes    noErr      No error
  13540.                 bdNamErr   Bad file name
  13541.                 dupFNErr   Duplicate file name and version
  13542.                 dirFulErr  File directory full
  13543.                 dirNFErr   Directory not found or incomplete pathname
  13544.                 extFSErr   External file system
  13545.                 ioErr      I/O error
  13546.                 nsvErr     No such volume
  13547.                 vLckdErr   Software volume lock
  13548.                 wPrErr     Hardware volume lock
  13549.     
  13550.  
  13551. æKY PBEject
  13552. æFp Files.p
  13553. æT FUNCTION
  13554. æTN $A017
  13555. æD FUNCTION PBEject(paramBlock: ParmBlkPtr): OSErr;
  13556. æDT myVariable := PBEject(paramBlock);
  13557. æMM   
  13558. æRI PBEject function II-107, IV-135
  13559. æC 
  13560. Trap macro    _Eject
  13561.  
  13562. Parameter block
  13563.   -->    12    ioCompletion  pointer
  13564.   <--    16    ioResult      word
  13565.   -->    18    ioNamePtr     pointer
  13566.   -->    22    ioVRefNum     word
  13567.  
  13568. PBEject flushes the volume specified by ioNamePtr or ioVRefNum, places it
  13569. off-line, and then ejects the volume.
  13570.  
  13571. Assembly-language note:  You may invoke the macro _Eject asynchronously;
  13572.                          the first part of the call is executed synchronously,
  13573.                          and the actual ejection is executed asynchronously.
  13574.  
  13575. Result codes    noErr     No error
  13576.                 bdNamErr  Bad volume name
  13577.                 extFSErr  External file system
  13578.                 ioErr     I/O error
  13579.                 nsDrvErr  No such drive
  13580.                 nsvErr    No such volume
  13581.                 paramErr  No default volume
  13582.  
  13583. æKY PBFlushFile
  13584. æFp Files.p
  13585. æT FUNCTION
  13586. æTN $A045
  13587. æD FUNCTION PBFlushFile(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13588. æDT myVariable := PBFlushFile(paramBlock,async);
  13589. æRI PBFlushFile function II-114, IV-144
  13590. æC 
  13591. Trap macro    _FlushFile
  13592.  
  13593. Parameter block
  13594.   -->    12    ioCompletion  pointer
  13595.   <--    16    ioResult      word
  13596.   -->    24    ioRefNum      word
  13597.  
  13598. PBFlushFile writes the contents of the access path buffer indicated by ioRefNum to
  13599. the volume, and updates the file’s entry in the file directory (or in the file catalog,
  13600. in the case of hierarchical volumes).
  13601.  
  13602. Warning:  Some information stored on the volume won’t be correct
  13603.           until PBFlushVol is called.
  13604.  
  13605. Result codes    noErr      No error
  13606.                 extFSErr   External file system
  13607.                 fnfErr     File not found
  13608.                 fnOpnErr   File not open
  13609.                 ioErr      I/O error
  13610.                 nsvErr     No such volume
  13611.                 rfNumErr   Bad reference number
  13612.  
  13613. æKY PBFlushVol
  13614. æFp Files.p
  13615. æT FUNCTION
  13616. æTN $A013
  13617. æD FUNCTION PBFlushVol(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13618. æDT myVariable := PBFlushVol(paramBlock,async);
  13619. æMM   
  13620. æRI PBFlushVol function II-105, IV-133
  13621. æC 
  13622. Trap macro    _FlushVol
  13623.  
  13624. Parameter block
  13625.   -->    12    ioCompletion  pointer
  13626.   <--    16    ioResult      word
  13627.   -->    18    ioNamePtr     pointer
  13628.   -->    22    ioVRefNum     word
  13629.  
  13630. On the volume specified by ioNamePtr or ioVRefNum, PBFlushVol writes descriptive
  13631. information about the volume, the contents of the associated volume buffer, and all
  13632. access path buffers for the volume (if they’ve changed since the last time PBFlushVol
  13633. was called).
  13634.  
  13635. Note:  The date and time of the last modification to the volume are set
  13636.        when the modification is made, not when the volume is flushed.
  13637.  
  13638. Result codes    noErr     No error
  13639.                 bdNamErr  Bad volume name
  13640.                 extFSErr  External file system
  13641.                 ioErr     I/O error
  13642.                 nsDrvErr  No such drive
  13643.                 nsvErr    No such volume
  13644.                 paramErr  No default volume
  13645.  
  13646. æKY PBGetCatInfo
  13647. æFp Files.p
  13648. æT FUNCTION
  13649. æD FUNCTION PBGetCatInfo(paramBlock: CInfoPBPtr;async: BOOLEAN): OSErr;
  13650. æDT myVariable := PBGetCatInfo(paramBlock,async);
  13651. æRT 68,69
  13652. æRI PBGetCatInfo function  IV-155,  V-391, N68-1, N69
  13653. æC 
  13654. •••Rrefer to Technical Note #69:•••
  13655.  
  13656. Trap macro    _GetCatInfo
  13657.  
  13658. Parameter block
  13659.   Files:                                   Directories:
  13660.   -->    12    ioCompletion   pointer      -->    12    ioCompletion  pointer
  13661.   <--    16    ioResult       word         <--    16    ioResult      word
  13662.   <->    18    ioNamePtr      pointer      <->    18    ioNamePtr     pointer
  13663.   -->    22    ioVRefNum      word         -->    22    ioVRefNum     word
  13664.   <--    24    ioFRefNum      word         <--    24    ioFRefNum     word
  13665.   -->    28    ioFDirIndex    word         -->    28    ioFDirIndex   word
  13666.   <--    30    ioFlAttrib     byte         <--    30    ioFlAttrib    byte
  13667.   <--    31    ioACUser       byte         access rights for directory only
  13668.   <--    32    ioFlFndrInfo   16 bytes     <--    32    ioDrUsrWds    16 bytes
  13669.   <->    48    ioDirID        long word    <->    48    ioDrDirID     long word
  13670.   <--    52    ioFlStBlk      word         <--    52    ioDrNmFls     word
  13671.   <--    54    ioFlLgLen      long word
  13672.   <--    58    ioFlPyLen      long word
  13673.   <--    62    ioFlRStBlk     word
  13674.   <--    64    ioFlRLgLen     long word
  13675.   <--    68    ioFlRPyLen     long word
  13676.   <--    72    ioFlCrDat      long word    <--    72    ioDrCrDat    long word
  13677.   <--    76    ioFlMdDat      long word    <--    76    ioDrMdDat    long word
  13678.   <--    80    ioFlBkDat      long word    <--    80    ioDrBkDat    long word
  13679.   <--    84    ioFlXFndrInfo  16 bytes     <--    84    ioDrFndrInfo 16 bytes
  13680.   <--    100   ioFlParID      long word    <--    100    ioDrParID   long word
  13681.   <--    104   ioFlClpSiz     long word
  13682.  
  13683. PBGetCatInfo gets information about the files and directories in a file catalog. To
  13684. determine whether the information is for a file or a directory, test bit 4 of ioFlAttrib,
  13685. as described in the section “CInfoPBRec”. The information that’s returned for files
  13686. is shown in the left column, and the corresponding information for directories is
  13687. shown in the right column.
  13688.  
  13689. If ioFDirIndex is positive, the File Manager returns information about the file or
  13690. directory whose directory index is ioFDirIndex in the directory specified by ioVRefNum
  13691. (this will be the root directory if a volume reference number is provided).
  13692.  
  13693. If ioFDirIndex is 0, the File Manager returns information about the file or directory
  13694. specified by ioNamePtr, in the directory specified by ioVRefNum
  13695. (again, this will be the root directory if a volume reference number is provided).
  13696.  
  13697. If ioFDirIndex is negative, the File Manager ignores ioNamePtr and returns information
  13698. about the directory specified by ioDirID.
  13699.  
  13700. With files, PBGetCatInfo is similar to PBHGetFileInfo but returns some additional
  13701. information. If the file is open, the reference number of the first access path found
  13702. is returned in ioFRefNum, and the name of the file is returned in ioNamePtr (unless
  13703. ioNamePtr is NIL).
  13704.  
  13705. For server volume directories, in addition to the normal return parameters the ioACUser
  13706. field returns the user’s access rights in the following format:
  13707.  
  13708.   Bit    7    if set, user is not the owner of the directory.
  13709.               if clear, user is the owner of the directory.
  13710.          6–3  Reserved; this is returned set to zero.
  13711.          2    If set, user does not have Make Changes privileges
  13712.               to the directory.
  13713.               If clear, user has Make Changes privileges to the directory.
  13714.          1    If set, user does not have See Files privileges to the directory.
  13715.               If clear, user has See Files privileges to the directory.
  13716.          0    If set, user does not have See Folders privileges
  13717.               to the directory.
  13718.               If clear, user has See Folders privileges to the directory.
  13719.  
  13720. For example, if ioACUser returns zero for a given server volume directory, you know
  13721. that the user is the owner of the directory and has complete privileges to it.
  13722.  
  13723. Result codes    noErr     No error
  13724.                 bdNamErr  Bad file name
  13725.                 dirNFErr  Directory not found or incomplete pathname
  13726.                 extFSErr  External file system
  13727.                 fnfErr    File not found
  13728.                 ioErr     I/O error
  13729.                 nsvErr    No such volume
  13730.                 paramErr  No default volume
  13731.  
  13732. æKY PBGetEOF
  13733. æFp Files.p
  13734. æT FUNCTION
  13735. æTN $A011
  13736. æD FUNCTION PBGetEOF(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13737. æDT myVariable := PBGetEOF(paramBlock,async);
  13738. æRI PBGetEOF function II-112, IV-142
  13739. æC 
  13740. Trap macro    _GetEOF
  13741.  
  13742. Parameter block
  13743.   -->    12    ioCompletion  pointer
  13744.   <--    16    ioResult      word
  13745.   -->    24    ioRefNum      word
  13746.   <--    28    ioMisc        long word
  13747.  
  13748. PBGetEOF returns, in ioMisc, the logical end-of-file of the open file whose access
  13749. path is specified by ioRefNum.
  13750.  
  13751. Result codes    noErr     No error
  13752.                 extFSErr  External file system
  13753.                 fnOpnErr  File not open
  13754.                 ioErr     I/O error
  13755.                 rfNumErr  Bad reference number
  13756.  
  13757. æKY PBGetFCBInfo
  13758. æFp Files.p
  13759. æT FUNCTION
  13760. æD FUNCTION PBGetFCBInfo(paramBlock: FCBPBPtr;async: BOOLEAN): OSErr;
  13761. æDT myVariable := PBGetFCBInfo(paramBlock,async);
  13762. æRT 87
  13763. æRI PBGetFCBInfo function  IV-179, N87-1
  13764. æC  
  13765. Trap macro    _GetFCBInfo
  13766.  
  13767. Parameter block
  13768.   -->    12    ioCompletion  pointer
  13769.   <--    16    ioResult      word
  13770.   <--    18    ioNamePtr     pointer
  13771.   <->    22    ioVRefNum     word
  13772.   <->    24    ioRefNum      word
  13773.   -->    28    ioFCBIndx     long word
  13774.   <--    32    ioFCBFlNm     long word
  13775.   <--    36    ioFCBFlags    word
  13776.   <--    38    ioFCBStBlk    word
  13777.   <--    40    ioFCBEOF      long word
  13778.   <--    44    ioFCBPLen     long word
  13779.   <--    48    ioFCBCrPs     long word
  13780.   <--    52    ioFCBVRefNum  word
  13781.   <--    54    ioFCBClpSiz   long word
  13782.   <--    58    ioFCBParID    long word
  13783.  
  13784. PBGetFCBInfo returns information about the specified open file. If ioFCBIndx is
  13785. positive, the File Manager returns information about the file whose file number is
  13786. ioFCBIndx on the volume specified by ioVRefNum (which may contain a drive number,
  13787. volume reference number, or working directory reference number). If ioVRefNum is 0,
  13788. all open files are indexed; otherwise, only open files on the specified volume are
  13789. indexed.
  13790.  
  13791. If ioFCBIndx is 0, the File Manager returns information about the file whose access
  13792. path is specified by ioRefNum.
  13793.  
  13794. Assembly-language note:  The global variable FCBSPtr points to the
  13795.                          length word of the file-control-block buffer.
  13796.  
  13797. Each file control block contains 94 bytes of information about an access path; Figure
  13798. 28 shows its structure (using the assembly-language offsets).
  13799.  
  13800. •••Refer to Figure 28:•••
  13801.  
  13802. Figure 28–A File Control Block
  13803.  
  13804. 64K ROM note:  The structure of a file control block in the 64K ROM
  13805.                version of the File Manager is a subset of the above
  13806.                structure. The old file control block contained only
  13807.                the fields up to and including fcbFlPos.
  13808.  
  13809. FCBMdRByt (which corresponds to ioFCBFlags in the parameter block for PBGetFCBInfo)
  13810. contains flags that describe the status of the file, as follows:
  13811.  
  13812.   Bit    Meaning
  13813.   0     Set if data can be written to the file
  13814.   1     Set if the entry describes a resource fork
  13815.   7     Set if the file has been changed since it was last flushed
  13816.  
  13817. Warning:  The size and structure of a file control block may be
  13818.           different in future versions of Macintosh system software.
  13819.  
  13820. æKY PBGetFInfo
  13821. æFp Files.p
  13822. æT FUNCTION
  13823. æD FUNCTION PBGetFInfo(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13824. æDT myVariable := PBGetFInfo(paramBlock,async);
  13825. æRT 24
  13826. æRI PBGetFInfo function II-115, IV-148, N24-1, N68-1
  13827. æC 
  13828. Trap macro    _GetFileInfo
  13829.  
  13830. Parameter block
  13831.   -->    12    ioCompletion  pointer
  13832.   <--    16    ioResult      word
  13833.   <->    18    ioNamePtr     pointer
  13834.   -->    22    ioVRefNum     word
  13835.   <--    24    ioFRefNum     word
  13836.   -->    26    ioFVersNum    byte
  13837.   -->    28    ioFDirIndex   word
  13838.   <--    30    ioFlAttrib    byte
  13839.   <--    31    ioFlVersNum   byte
  13840.   <--    32    ioFlFndrInfo  16 bytes
  13841.   <--    48    ioFlNum       long word
  13842.   <--    52    ioFlStBlk     word
  13843.   <--    54    ioFlLgLen     long word
  13844.   <--    58    ioFlPyLen     long word
  13845.   <--    62    ioFlRStBlk    word
  13846.   <--    64    ioFlRLgLen    long word
  13847.   <--    68    ioFlRPyLen    long word
  13848.   <--    72    ioFlCrDat     long word
  13849.   <--    76    ioFlMdDat     long word
  13850.  
  13851. PBGetFInfo returns information about the specified file. If ioFDirIndex is positive,
  13852. the File Manager returns information about the file whose directory index is ioFDirIndex
  13853. on the volume specified by ioVRefNum. (See the section
  13854. “Data Organization on Volumes” if you’re interested in using this method.)
  13855.  
  13856. Note:  If a working directory reference number is specified in ioVRefNum,
  13857.        the File Manager returns information about the file whose directory
  13858.        index is ioFDirIndex in the specified directory.
  13859.  
  13860. If ioFDirIndex is negative or 0, the File Manager returns information about the file
  13861. having the name pointed to by ioNamePtr (and on flat volumes, the version number
  13862. ioFVersNum) on the volume specified by ioVRefNum. If the file is open, the reference
  13863. number of the first access path found is returned in ioFRefNum, and the name of the
  13864. file is returned in ioNamePtr (unless ioNamePtr is NIL).
  13865.  
  13866. Result codes    noErr     No error
  13867.                 bdNamErr  Bad file name
  13868.                 extFSErr  External file system
  13869.                 fnfErr    File not found
  13870.                 ioErr     I/O error
  13871.                 nsvErr    No such volume
  13872.                 paramErr  No default volume
  13873.  
  13874. æKY PBGetFPos
  13875. æFp Files.p
  13876. æT FUNCTION
  13877. æTN $A018
  13878. æD FUNCTION PBGetFPos(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13879. æDT myVariable := PBGetFPos(paramBlock,async);
  13880. æRI PBGetFPos function II-111, IV-141
  13881. æC 
  13882. Trap macro    _GetFPos
  13883.  
  13884. Parameter block
  13885.   -->    12    ioCompletion  pointer
  13886.   <--    16    ioResult      word
  13887.   -->    24    ioRefNum      word
  13888.   <--    36    ioReqCount    long word
  13889.   <--    40    ioActCount    long word
  13890.   <--    44    ioPosMode     word
  13891.   <--    46    ioPosOffset   long word
  13892.  
  13893. PBGetFPos returns, in ioPosOffset, the mark of the open file whose access path is
  13894. specified by ioRefNum. It sets ioReqCount, ioActCount, and ioPosMode to 0.
  13895.  
  13896. Result codes    noErr     No error
  13897.                 extFSErr  External file system
  13898.                 fnOpnErr  File not open
  13899.                 gfpErr    Error during GetFPos
  13900.                 ioErr     I/O error
  13901.                 rfNumErr  Bad reference number
  13902.  
  13903. æKY PBGetVInfo
  13904. æFp Files.p
  13905. æT FUNCTION
  13906. æTN $A007
  13907. æD FUNCTION PBGetVInfo(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13908. æDT myVariable := PBGetVInfo(paramBlock,async);
  13909. æRT 24, 44, 157
  13910. æRI PBGetVInfo function II-104, IV-129, N24-1, N44-2, N157
  13911. æC 
  13912. Trap macro    _GetVolInfo
  13913.  
  13914. Parameter block
  13915.   -->    12    ioCompletion  pointer
  13916.   <--    16    ioResult      word
  13917.   <->    18    ioNamePtr     pointer
  13918.   <->    22    ioVRefNum     word
  13919.   -->    28    ioVolIndex    word
  13920.   <--    30    ioVCrDate     long word
  13921.   <--    34    ioVLsBkUp     long word
  13922.   <--    38    ioVAtrb       word
  13923.   <--    40    ioVNmFls      word
  13924.   <--    42    ioVDirSt      word
  13925.   <--    44    ioVBlLn       word
  13926.   <--    46    ioVNmAlBlks   word
  13927.   <--    48    ioVAlBlkSiz   long word
  13928.   <--    52    ioVClpSiz     long word
  13929.   <--    56    ioAlBlSt      word
  13930.   <--    58    ioVNxtFNum    long word
  13931.   <--    62    ioVFrBlk      word
  13932.  
  13933. PBGetVInfo returns information about the specified volume. If ioVolIndex is positive,
  13934. the File Manager attempts to use it to find the volume; for instance, if ioVolIndex
  13935. is 2, the File Manager will attempt to access the second mounted volume. If ioVolIndex
  13936. is negative, the File Manager uses ioNamePtr and ioVRefNum in the standard way (described
  13937. in the section “Specifying Volumes, Directories, and Files”) to determine which
  13938. volume. If ioVolIndex is 0, the File Manager attempts to access the volume by using
  13939. ioVRefNum only. The volume reference number is returned in ioVRefNum, and a pointer
  13940. to the volume name is returned in ioNamePtr (unless ioNamePtr is NIL).
  13941.  
  13942. If a working directory reference number is passed in ioVRefNum (or if the default
  13943. directory is a subdirectory), the number of files and directories in the specified
  13944. directory (the directory’s valence) will be returned in ioVNmFls. Also, the volume
  13945. reference number won’t be returned; ioVRefNum will still contain the working directory
  13946. reference number.
  13947.  
  13948. Warning:  IOVNmAlBlks and ioVFrBlks, which are actually unsigned integers,
  13949.           are clipped to 31744 ($7C00) regardless of the size of the volume.
  13950.  
  13951. Result codes    noErr       No error
  13952.                 nsvErr      No such volume
  13953.                 paramErr    No default volume
  13954.  
  13955. æKY PBGetVol
  13956. æFp Files.p
  13957. æT FUNCTION
  13958. æTN $A014
  13959. æD FUNCTION PBGetVol(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  13960. æDT myVariable := PBGetVol(paramBlock,async);
  13961. æRI PBGetVol function II-104, IV-131
  13962. æC 
  13963. Trap macro    _GetVol
  13964.  
  13965. Parameter block
  13966.   -->    12    ioCompletion  pointer
  13967.   <--    16    ioResult      word
  13968.   <--    18    ioNamePtr     pointer
  13969.   <--    22    ioVRefNum     word
  13970.  
  13971. PBGetVol returns a pointer to the name of the default volume in ioNamePtr
  13972. (unless ioNamePtr is NIL) and its volume reference number in ioVRefNum. If a default
  13973. directory was set with a previous PBSetVol call, a pointer to its name will be returned
  13974. in ioNamePtr and its working directory reference number in ioVRefNum.
  13975.  
  13976. Result codes    noErr     No error
  13977.                 nsvErr    No default volume
  13978.  
  13979. æKY PBGetWDInfo
  13980. æFp Files.p
  13981. æT FUNCTION
  13982. æD FUNCTION PBGetWDInfo(paramBlock: WDPBPtr;async: BOOLEAN): OSErr;
  13983. æDT myVariable := PBGetWDInfo(paramBlock,async);
  13984. æRT 77, 190
  13985. æRI PBGetWDInfo function  IV-159, N77-5
  13986. æC 
  13987. Trap macro    _GetWDInfo
  13988.  
  13989. Parameter block
  13990.   -->    12    ioCompletion  pointer
  13991.   <--    16    ioResult      word
  13992.   <--    18    ioNamePtr     pointer
  13993.   <->    22    ioVRefNum     word
  13994.   -->    26    ioWDIndex     word
  13995.   <->    28    ioWDProcID    long word
  13996.   <->    32    ioWDVRefNum   word
  13997.   <--    48    ioWDDirID     long word
  13998.  
  13999. PBGetWDInfo returns information about the specified working directory. The working
  14000. directory can be specified either by its working directory reference number in ioVRefNum
  14001. (in which case ioWDIndex should be 0), or by its index number in ioWDIndex. In the
  14002. latter case, if ioVRefNum is nonzero, it’s interpreted as a volume specification
  14003. (volume reference number or drive number), and only working directories on that
  14004. volume are indexed.
  14005.  
  14006. IOWDVRefNum always returns the volume reference number. IOVRefNum returns a working
  14007. directory reference number when a working directory reference number is passed in
  14008. that field; otherwise, it returns a volume reference number. The volume name is
  14009. returned in ioNamePtr.
  14010.  
  14011. If IOWDProcID is nonzero, only working directories with that identifier are indexed;
  14012. otherwise all working directories are indexed.
  14013.  
  14014. Result codes    noErr     No error
  14015.                 nsvErr    No such volume
  14016.  
  14017. æKY PBHCopyFile
  14018. æFp Files.p
  14019. æT FUNCTION
  14020. æD FUNCTION PBHCopyFile(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14021. æDT myVariable := PBHCopyFile(paramBlock,async);
  14022. æRI PBHCopyFile function  V-396
  14023. æC 
  14024. Trap macro    _CopyFile
  14025.  
  14026. Parameter block
  14027.   -->    12    ioCompletion  long    optional completion routine ptr
  14028.   <--    16    ioResult      word    error result code
  14029.   -->    18    ioFileName    long    ptr to source pathname
  14030.   -->    22    ioVRefNum     word    source vol identifier
  14031.   -->    24    ioDstVRefNum  word    destination vol identifier
  14032.   -->    28    ioNewName     long    ptr to destination pathname
  14033.   -->    32    ioCopyName    long    ptr to optional name (may be NIL)
  14034.   -->    36    ioNewDirID    long    destination directory ID
  14035.   -->    48    ioDirID       long    source directory ID
  14036.  
  14037. PBHCopyFile duplicates a file on the volume and optionally renames it.  It is an
  14038. optional call for AppleShare file servers.  You should examine the returned flag
  14039. information in the PBHGetVolParms call to see if this volume supports CopyFile.
  14040.  
  14041. For AppleShare file servers, the source and destination pathnames must indicate the
  14042. same file server; however, it may point to a different volume for that file server. 
  14043. A useful way to tell if two file server volumes are on the same file server is to
  14044. make the GetVolParms call and compare the server addresses returned.  The server will
  14045. open source files with read/deny write enabled and destination files with write/deny
  14046. read and write enabled.
  14047.  
  14048. IOVRefNum contains a source volume identifier.  The source pathname is determined by
  14049. the ioFileName/ioDirID pair.  IODstVRefNum contains a destination volume identifier. 
  14050. AppleShare 1.0 required that it be an actual volume reference number; however, on
  14051. future versions it can be a WDRefNum.  The destination pathname is determined by the
  14052. ioNewName/ioNewDirID pair.  IOCopyName may contain an optional string used in renaming
  14053. the file.  If it is non-NIL then the file copy will be renamed to the specified name
  14054. in ioCopyName.
  14055.  
  14056. A fnfErr is returned if the source pathname does not point to an existing file or the
  14057. destination pathname does not point to an existing directory.  An AccessDenied error
  14058. is returned if the user does not have the right to read the source or write to the
  14059. destination.  A dupFnErr is returned if the destination already exists.  A DenyConflict
  14060. error is returned if either the source or destination file could not be opened under
  14061. the access modes described above.
  14062.  
  14063. æKY PBHCreate
  14064. æFp Files.p
  14065. æT FUNCTION
  14066. æD FUNCTION PBHCreate(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14067. æDT myVariable := PBHCreate(paramBlock,async);
  14068. æRI PBHCreate function IV-146 
  14069. æC 
  14070. Trap macro    _HCreate
  14071.  
  14072. Parameter block
  14073.   -->    12    ioCompletion  pointer
  14074.   <--    16    ioResult      word
  14075.   -->    18    ioNamePtr     pointer
  14076.   -->    22    ioVRefNum     word
  14077.   -->    48    ioDirID       long word
  14078.  
  14079. PBHCreate is identical to PBCreate except that it accepts a directory ID in ioDirID.
  14080.  
  14081. Note:  To create a directory instead of a file, call PBDirCreate.
  14082.  
  14083. Result codes    noErr      No error
  14084.                 bdNamErr   Bad file name
  14085.                 dupFNErr   Duplicate file name and version
  14086.                 dirFulErr  File directory full
  14087.                 dirNFErr   Directory not found or incomplete pathname
  14088.                 extFSErr   External file system
  14089.                 ioErr      I/O error
  14090.                 nsvErr     No such volume
  14091.                 vLckdErr   Software volume lock
  14092.                 wPrErr     Hardware volume lock
  14093.  
  14094. æKY PBHDelete
  14095. æFp Files.p
  14096. æT FUNCTION
  14097. æD FUNCTION PBHDelete(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14098. æDT myVariable := PBHDelete(paramBlock,async);
  14099. æRI PBHDelete function IV-147
  14100. æC 
  14101. Trap macro    _HDelete
  14102.  
  14103. Parameter block
  14104.   -->    12    ioCompletion  pointer
  14105.   <--    16    ioResult      word
  14106.   -->    18    ioNamePtr     pointer
  14107.   -->    22    ioVRefNum     word
  14108.   -->    48    ioDirID       long word
  14109.  
  14110. PBHDelete is identical to PBDelete except that it accepts a directory ID in ioDirID.
  14111. PBHDelete can be used to delete an empty directory as well.
  14112.  
  14113. Result codes    noErr     No error
  14114.                 bdNamErr  Bad file name
  14115.                 dirNFErr  Directory not found or incomplete pathname
  14116.                 extFSErr  External file system
  14117.                 fBsyErr   File busy, directory not empty, or working
  14118.                           directory control block open
  14119.                 fLckdErr  File locked
  14120.                 fnfErr    File not found
  14121.                 nsvErr    No such volume
  14122.                 ioErr     I/O error
  14123.                 vLckdErr  Software volume lock
  14124.                 wPrErr    Hardware volume lock
  14125.  
  14126. æKY PBHGetDirAccess
  14127. æFp Files.p
  14128. æT FUNCTION
  14129. æD FUNCTION PBHGetDirAccess(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14130. æDT myVariable := PBHGetDirAccess(paramBlock,async);
  14131. æRI PBHGetDirAccess function  V-394
  14132. æC 
  14133. Trap macro    _GetDirAccess
  14134.  
  14135. Parameter block
  14136.   -->    12    ioCompletion  long    optional completion routine ptr
  14137.   <--    16    ioResult      word    error result code
  14138.   -->    18    ioFileName    long    directory name
  14139.   -->    22    ioVRefNum     word    volume refNum
  14140.   <--    36    ioACOwnerID   long    owner ID
  14141.   <--    40    ioACGroupID   long    group ID
  14142.   <--    44    ioACAccess    long    access rights
  14143.   -->    48    ioDirID       long    directory ID
  14144.  
  14145. PBHGetDirAccess returns access control information for the folder pointed to by the
  14146. ioDirID/ioFIleName pair.  ioACOwnerID will return the ID for the folder’s owner. 
  14147. ioACGroupID will return the ID for the folder’s primary group.  The access rights are
  14148. returned in ioACAccess.
  14149.  
  14150. A fnfErr is returned if the pathname does not point to a valid directory.  An AccessDenied
  14151. error is returned if the user does not have the correct access rights to examine this
  14152. directory.
  14153.  
  14154. æKY PBHGetFInfo
  14155. æFp Files.p
  14156. æT FUNCTION
  14157. æD FUNCTION PBHGetFInfo(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14158. æDT myVariable := PBHGetFInfo(paramBlock,async);
  14159. æRI PBHGetFInfo function IV-149 
  14160. æC 
  14161. Trap macro    _HGetFileInfo
  14162.  
  14163. Parameter block
  14164.   -->    12    ioCompletion  pointer
  14165.   <--    16    ioResult      word
  14166.   <->    18    ioNamePtr     pointer
  14167.   -->    22    ioVRefNum     word
  14168.   <--    24    ioFRefNum     word
  14169.   -->    28    ioFDirIndex   word
  14170.   <--    30    ioFlAttrib    byte
  14171.   <--    32    ioFlFndrInfo  16 bytes
  14172.   <->    48    ioDirID       long word
  14173.   <--    52    ioFlStBlk     word
  14174.   <--    54    ioFlLgLen     long word
  14175.   <--    58    ioFlPyLen     long word
  14176.   <--    62    ioFlRStBlk    word
  14177.   <--    64    ioFlRLgLen    long word
  14178.   <--    68    ioFlRPyLen    long word
  14179.   <--    72    ioFlCrDat     long word
  14180.   <--    76    ioFlMdDat     long word
  14181.  
  14182. PBHGetFInfo is identical to PBGetFInfo except that it accepts a directory ID in
  14183. ioDirID.
  14184.  
  14185. Result codes    noErr     No error
  14186.                 bdNamErr  Bad file name
  14187.                 dirNFErr  Directory not found or incomplete pathname
  14188.                 extFSErr  External file system
  14189.                 fnfErr    File not found
  14190.                 ioErr     I/O error
  14191.                 nsvErr    No such volume
  14192.                 paramErr  No default volume
  14193.  
  14194. æKY PBHGetLogInInfo
  14195. æFp Files.p
  14196. æT FUNCTION
  14197. æD FUNCTION PBHGetLogInInfo(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14198. æDT myVariable := PBHGetLogInInfo(paramBlock,async);
  14199. æRI PBHGetLogInInfo function  V-393
  14200. æC 
  14201. Trap macro    _GetLogInInfo
  14202.  
  14203. Parameter block
  14204.   -->    12    ioCompletion  long    optional completion routine ptr
  14205.   <--    16    ioResult      word    error result code
  14206.   -->    22    ioVRefNum     word    volume refNum
  14207.   <--    26    ioObjType     word    log in method
  14208.   <--    28    ioObjNamePtr  long    ptr to log in name buffer
  14209.  
  14210. PBHGetLogInInfo returns the method used for log-in and the user name specified at
  14211. log-in time for the volume.  The log-in user name is returned as a Pascal string in
  14212. ioObjNamePtr.  The maximum size of the user name is 31 characters.  The log-in method
  14213. type is returned in ioObjType.
  14214.  
  14215. æKY PBHGetVInfo
  14216. æFp Files.p
  14217. æT FUNCTION
  14218. æD FUNCTION PBHGetVInfo(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14219. æDT myVariable := PBHGetVInfo(paramBlock,async);
  14220. æRT 24, 66, 67, 77, 106, 157
  14221. æRI PBHGetVInfo function IV-130, N66-1, N67-1, N77-5  
  14222. æC 
  14223. Trap macro    _HGetVInfo
  14224.  
  14225. Parameter block
  14226.   -->    12    ioCompletion  pointer
  14227.   <--    16    ioResult      word
  14228.   <->    18    ioNamePtr     pointer
  14229.   <->    22    ioVRefNum     word
  14230.   -->    28    ioVolIndex    word
  14231.   <--    30    ioVCrDate     long word
  14232.   <--    34    ioVLsMod      long word
  14233.   <--    38    ioVAtrb       word
  14234.   <--    40    ioVNmFls      word
  14235.   <--    42    ioVBitMap     word
  14236.   <--    44    ioVAllocPtr   word
  14237.   <--    46    ioVNmAlBlks   word
  14238.   <--    48    ioVAlBlkSiz   long word
  14239.   <--    52    ioVClpSiz     long word
  14240.   <--    56    ioAlBlSt      word
  14241.   <--    58    ioVNxtFNum    long word
  14242.   <--    62    ioVFrBlk      word
  14243.   <--    64    ioVSigWord    word
  14244.   <--    66    ioVDrvInfo    word
  14245.   <--    68    ioVDRefNum    word
  14246.   <--    70    ioVFSID       word
  14247.   <--    72    ioVBkUp       long word
  14248.   <--    76    ioVSeqNum     word
  14249.   <--    78    ioVWrCnt      long word
  14250.   <--    82    ioVFilCnt     long word
  14251.   <--    86    ioVDirCnt     long word
  14252.   <--    90    ioVFndrInfo   32 bytes
  14253.  
  14254. PBHGetVInfo is similar in function to PBGetVInfo but returns a larger parameter
  14255. block. In addition, PBHGetVInfo always returns the volume reference number in ioVRefNum
  14256. (regardless of what was passed in). Also, ioVNmAlBlks and ioVFrBlks are not clipped
  14257. as they are by PBGetVInfo.
  14258.  
  14259. Result codes    noErr       No error
  14260.                 nsvErr      No such volume
  14261.                 paramErr    No default volume
  14262.  
  14263. æKY PBHGetVol
  14264. æFp Files.p
  14265. æT FUNCTION
  14266. æD FUNCTION PBHGetVol(paramBlock: WDPBPtr;async: BOOLEAN): OSErr;
  14267. æDT myVariable := PBHGetVol(paramBlock,async);
  14268. æRI PBHGetVol function IV-132 
  14269. æC 
  14270. Trap macro    _HGetVol
  14271.  
  14272. Parameter block
  14273.   -->    12    ioCompletion  pointer
  14274.   <--    16    ioResult      word
  14275.   <--    18    ioNamePtr     pointer
  14276.   <--    22    ioVRefNum     word
  14277.   <--    28    ioWDProcID    long word
  14278.   <--    32    ioWDVRefNum   word
  14279.   <--    48    ioWDDirID     long word
  14280.  
  14281. PBHGetVol returns the default volume and directory last set by either a PBSetVol or a
  14282. PBHSetVol call. The reference number of the default volume is returned in ioVRefNum.
  14283.  
  14284. Warning:  IOVRefNum will return a working directory reference number
  14285.           (instead of the volume reference number) if, in the last call
  14286.           to PBSetVol or PBHSetVol, a working directory reference number
  14287.           was passed in this field.
  14288.  
  14289. The volume reference number of the volume on which the default directory exists is
  14290. returned in ioWDVRefNum. The directory ID of the default directory is returned in
  14291. ioWDDirID.
  14292.  
  14293. Result codes    noErr     No error
  14294.                 nsvErr    No default volume
  14295.  
  14296. æKY PBHGetVolParms
  14297. æFp Files.p
  14298. æT FUNCTION
  14299. æD FUNCTION PBHGetVolParms(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14300. æDT myVariable := PBHGetVolParms(paramBlock,async);
  14301. æRI PBHGetVolParms function  V-392
  14302. æC 
  14303. Trap macro    _GetVolParms
  14304.  
  14305. Parameter block
  14306.   -->    12    ioCompletion  long    optional completion routine ptr
  14307.   <--    16    ioResult      word    error result code
  14308.   -->    18    ioFileName    long    volume name specifier
  14309.   -->    22    ioVRefNum     word    volume refNum
  14310.   <--    32    ioBuffer      long    ptr to vol parms data
  14311.   -->    36    ioReqCount    long    size of buffer area
  14312.   <--    40    ioActCount    long    length of vol parms data
  14313.  
  14314. The PBHGetVolParms call is used to return volume level information.  ioVRefNum or
  14315. ioFileName contain the volume identifier information.  ioReqCount and ioBuffer contain
  14316. the size and location of the buffer in which to place the volume parameters.  The
  14317. actual size of the information is returned in ioActCount.
  14318.  
  14319. The format of the buffer is described below.  Version 01 of the buffer is shown below
  14320. along with offsets into the buffer and their equates:
  14321.  
  14322. offset    0    vMVersion    word    version number (currently 01)
  14323.           2    vMAttrib     long    attributes (detailed below)
  14324.           6    vMLocalHand  long    handle used to keep information
  14325.                                     necessary for shared volumes
  14326.          10    vMServerAdr  long    AppleTalk server address (zero if
  14327.                                     not supported)
  14328.  
  14329. On creation of the VCB (right after mounting), vMLocalHand will be a handle to a 2
  14330. byte block of memory.  The Finder uses this for its local window list storage, allocating
  14331. and deallocating memory as needed.  It is disposed of when the volume is unmounted.
  14332.  
  14333. For AppleTalk server volumes, vMServerAdr contains the AppleTalk internet address of
  14334. the server.  This can be used to tell which volumes are for which server.
  14335.  
  14336. vMAttrib contains attributes information (32 flag bits) about the volume.  These bits
  14337. and their equates are defined as follows:
  14338.  
  14339. bit    31  bLimitFCBs      If set, Finder limits the number of FCBs used
  14340.                            during copies to 8 (instead of 16).
  14341.        30  bLocalWList     If set, Finder uses the returned shared volume
  14342.                            handle for its local window list.
  14343.        29  bNoMiniFndr     If set, Mini Finder menu item is disabled.
  14344.        28  bNoVNEdit       If set, volume name cannot be edited.
  14345.        27  bNoLclSync      If set, volume’s modification date is not set by
  14346.                            any Finder action.
  14347.        26  bTrshOffLine    If set, anytime volume goes offline, it is zoomed
  14348.                            to the Trash and unmounted.
  14349.        25  bNoSwitchTo     If set, Finder will not switch launch to any
  14350.                            application on the volume.
  14351.        24–21               Reserved—server volumes should return these
  14352.                            bits set, all other disks should return these
  14353.                            bits cleared.
  14354.        20  bNoDeskItems    If set, no items may be placed on the Finder desktop.
  14355.        19  bNoBootBlks     If set, no boot blocks on this volume—not a startup
  14356.                            volume.  SetStartup menu item will be disabled;
  14357.                            bootblocks will not be copied during copy operations.
  14358.        18  bAccessCntl     If set, volume supports AppleTalk AFP access control
  14359.                            interfaces.  The calls GetLoginInfo, GetDirAccess,
  14360.                            SetDirAccess, MapID, and MapName are supported.
  14361.                            Special folder icons are used.  Access Privileges
  14362.                            menu item is enabled for disk and folder items. The
  14363.                            privileges field of GetCatInfo calls are assumed to
  14364.                            be valid.
  14365.        17  bNoSysDir       If set, volume doesn’t support a system directory;
  14366.                            no switch launch to this volume.
  14367.        16  bExtFSVol       If set, this volume is an external file system
  14368.                            volume.  Disk init package will not be called.
  14369.                            Erase Disk menu item is disabled.
  14370.        15  bHasOpenDeny    If set, supports _OpenDeny and _OpenRFDeny calls.
  14371.                            For copy operations, source files are opened with
  14372.                            enable read/deny write and destination files are
  14373.                            opened enable write/deny read and write.
  14374.        14  bHasCopyFile    If set, _CopyFile call supported.  _CopyFile is
  14375.                            used in copy and duplicate operations if both source
  14376.                            and destination volumes have same server address.
  14377.        13  bHasMoveRename  If set, _MoveRename call supported.
  14378.        12  bHasNewDesk     If set, all of the new desktop calls are supported
  14379.                            (for example, OpenDB, AddIcon, AddComment).
  14380.        11–0                Reserved—these bits should be returned cleared.
  14381.  
  14382. æKY PBHMapID
  14383. æFp Files.p
  14384. æT FUNCTION
  14385. æD FUNCTION PBHMapID(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14386. æDT myVariable := PBHMapID(paramBlock,async);
  14387. æRI PBHMapID function  V-395
  14388. æC 
  14389. Trap macro    _MapID
  14390.  
  14391. Parameter block
  14392.   -->    12    ioCompletion  long    optional completion routine ptr
  14393.   <--    16    ioResult      word    error result code
  14394.   -->    18    ioFileName    long    pathname identifier
  14395.   -->    22    ioVRefNum     word    volume refNum
  14396.   -->    26    ioObjType     word    function code
  14397.   <--    28    ioObjNamePtr  long    ptr to retrnd creator/group name
  14398.   -->    32    ioObjID       long    creator/group ID
  14399.  
  14400. PBHMapID returns the name of a user or group given its unique ID.  IOObjID contains
  14401. the ID to be mapped.  The value zero for ioObjID is special cased and will always
  14402. return a NIL name.  AppleShare uses this to signify <Any User>.  IOObjType is the
  14403. mapping function code; it’s 1 if you’re mapping an owner ID to owner name or 2 if
  14404. you’re mapping a group ID to a group name.  The name is returned as a Pascal string
  14405. in ioObjNamePtr.  The maximum size of the name is 31 characters.
  14406.  
  14407. A fnfErr is returned if an unrecognizable owner or group ID is passed.
  14408.  
  14409. æKY PBHMapName
  14410. æFp Files.p
  14411. æT FUNCTION
  14412. æD FUNCTION PBHMapName(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14413. æDT myVariable := PBHMapName(paramBlock,async);
  14414. æRI PBHMapName function  V-395
  14415. æC 
  14416. Trap macro    _MapName
  14417.  
  14418. Parameter block
  14419.   -->    12    ioCompletion  long    optional completion routine ptr
  14420.   <--    16    ioResult      word    error result code
  14421.   -->    18    ioFileName    long    volume identifier (may be NIL)
  14422.   -->    22    ioVRefNum     word    volume refNum
  14423.   -->    28    ioObjNamePtr  long    owner or group name
  14424.   -->    26    ioObjType     word    function code
  14425.   <--    32    ioObjID       long    creator/group ID
  14426.  
  14427. PBHMapName returns the unique user ID or group ID given its name.  The name is passed
  14428. as a string in ioObjNamePtr.  If a NIL name is passed, the ID returned will always be
  14429. zero.  The maximum size of the name is 31 characters.  IOObjType is the mapping
  14430. function code; it’s 3 if you’re mapping an owner name to owner ID or 4 if you’re
  14431. mapping a group name to a group ID.  IOObjID will contain the mapped ID.
  14432.  
  14433. A fnfErr is returned if an unrecognizable owner or group name is passed.
  14434.  
  14435. æKY PBHMoveRename
  14436. æFp Files.p
  14437. æT FUNCTION
  14438. æD FUNCTION PBHMoveRename(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14439. æDT myVariable := PBHMoveRename(paramBlock,async);
  14440. æRI PBHMoveRename function  V-397
  14441. æC 
  14442. Trap macro    _MoveRename
  14443.  
  14444. Parameter block
  14445.   -->    12    ioCompletion  long    optional completion routine ptr
  14446.   <--    16    ioResult      word    error result code
  14447.   -->    18    ioFileName    long    ptr to source pathname
  14448.   -->    22    ioVRefNum     word    source vol identifier
  14449.   -->    28    ioNewName     long    ptr to destination pathname
  14450.   -->    32    ioBuffer      long    ptr to optional name (may be NIL)
  14451.   -->    36    ioNewDirID    long    destination directory ID
  14452.   -->    48    ioDirID       long    source directory ID
  14453.  
  14454. PBHMoveRename allows you to move (not copy) an item and optionally to rename it.  The
  14455. source and destination pathnames must point to the same file server volume.
  14456.  
  14457. IOVRefNum contains a source volume identifier.  The source pathname is specified by
  14458. the ioFileName/ioDirID pair.  The destination pathname is specified by the ioNewName/ioNewDirID
  14459. pair.  IOBuffer may contain an optional string used in renaming the item.  If it is
  14460. non-NIL then the moved object will be renamed to the specified name in ioBuffer.
  14461.  
  14462. A fnfErr is returned if the source pathname does not point to an existing object.  An
  14463. AccessDenied error is returned if the user does not have the right to move the object.
  14464.  A dupFnErr is returned if the destination already exists.  A badMovErr is returned
  14465. if an attempt is made to move a directory into one of its descendent directories.
  14466.  
  14467. æKY PBHOpen
  14468. æFp Files.p
  14469. æT FUNCTION
  14470. æD FUNCTION PBHOpen(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14471. æDT myVariable := PBHOpen(paramBlock,async);
  14472. æRT 204
  14473. æRI PBHOpen function  IV-136 
  14474. æC 
  14475. Trap macro    _HOpen
  14476.  
  14477. Parameter block
  14478.   -->    12    ioCompletion  pointer
  14479.   <--    16    ioResult      word
  14480.   -->    18    ioNamePtr     pointer
  14481.   -->    22    ioVRefNum     word
  14482.   <--    24    ioRefNum      word
  14483.   -->    27    ioPermssn     byte
  14484.   -->    28    ioMisc        pointer
  14485.   -->    48    ioDirID       long word
  14486.  
  14487. PBHOpen is identical to PBOpen except that it accepts a directory ID in ioDirID.
  14488.  
  14489. Result codes    noErr     No error
  14490.                 bdNamErr  Bad file name
  14491.                 dirNFErr  Directory not found or incomplete pathname
  14492.                 extFSErr  External file system
  14493.                 fnfErr    File not found
  14494.                 ioErr     I/O error
  14495.                 nsvErr    No such volume
  14496.                 opWrErr   File already open for writing
  14497.                 permErr   Attempt to open locked file for writing
  14498.                 tmfoErr   Too many files open
  14499.  
  14500. æKY PBHOpenDeny
  14501. æFp Files.p
  14502. æT FUNCTION
  14503. æD FUNCTION PBHOpenDeny(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14504. æDT myVariable := PBHOpenDeny(paramBlock,async);
  14505. æRI PBHOpenDeny function  V-398
  14506. æC 
  14507. Trap macro    _OpenDeny
  14508.  
  14509. Parameter block
  14510.   -->    12    ioCompletion  long    optional completion routine ptr
  14511.   <--    16    ioResult      word    error result code
  14512.   -->    18    ioFileName    long    ptr to pathname
  14513.   -->    22    ioVRefNum     word    vol identifier
  14514.   <--    24    ioRefNum      word    file refNum
  14515.   -->    26    ioDenyModes   word    access rights data
  14516.   -->    48    ioDirID       long    directory ID
  14517.  
  14518. PBHOpenDeny opens a file’s data fork under specific access rights.  It creates an
  14519. access path to the file having the name pointed to by ioFileName/ioDirID.  The path
  14520. reference number is returned in ioRefNum.
  14521.  
  14522. IODenyModes contains a word of access rights information.  The format for these
  14523. access rights is:
  14524.  
  14525.     bits    15–6    Reserved—should be cleared.
  14526.             5       If set, other writers are denied access.
  14527.             4       If set, other readers are denied access.
  14528.             3–2     Reserved—should be cleared.
  14529.             1       If set, write permission requested.
  14530.             0       If set, read permission requested.
  14531.  
  14532. A fnfErr is returned if the input specification does not point to an existing file. 
  14533. A permErr is returned if the file is already open and you cannot open it under the
  14534. deny modes that you have specified.  An opWrErr is returned if you have asked for
  14535. write permission and the file is already opened by you for write.  The already opened
  14536. path reference number is returned in ioRefNum.  An AccessDenied error is returned if
  14537. you do not have the right to access the file.
  14538.  
  14539. æKY PBHOpenFile
  14540. æFp Files.p
  14541. æT FUNCTION
  14542. æD FUNCTION PBHOpenFile(paramBlock: HParmBlkPtr): OSErr;
  14543. æDT myVariable := PBHOpenFile(paramBlock);
  14544.  
  14545. æKY PBHOpenRF
  14546. æFp Files.p
  14547. æT FUNCTION
  14548. æD FUNCTION PBHOpenRF(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14549. æDT myVariable := PBHOpenRF(paramBlock,async);
  14550. æRI PBHOpenRF function IV-137
  14551. æC 
  14552. Trap macro    _HOpenRF
  14553.  
  14554. Parameter block
  14555.   -->    12    ioCompletion  pointer
  14556.   <--    16    ioResult      word
  14557.   -->    18    ioNamePtr     pointer
  14558.   -->    22    ioVRefNum     word
  14559.   <--    24    ioRefNum      word
  14560.   -->    27    ioPermssn     byte
  14561.   -->    28    ioMisc        pointer
  14562.   -->    48    ioDirID       long word
  14563.  
  14564. PBHOpenRF is identical to PBOpenRF except that it accepts a directory ID in ioDirID.
  14565.  
  14566. Result codes    noErr     No error
  14567.                 bdNamErr  Bad file name
  14568.                 dirNFErr  Directory not found or incomplete pathname
  14569.                 extFSErr  External file system
  14570.                 fnfErr    File not found
  14571.                 ioErr     I/O error
  14572.                 nsvErr    No such volume
  14573.                 opWrErr   File already open for writing
  14574.                 permErr   Attempt to open locked file for writing
  14575.                 tmfoErr   Too many files open
  14576.  
  14577. æKY PBHOpenRFDeny
  14578. æFp Files.p
  14579. æT FUNCTION
  14580. æD FUNCTION PBHOpenRFDeny(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14581. æDT myVariable := PBHOpenRFDeny(paramBlock,async);
  14582. æRI PBHOpenRFDeny function  V-398
  14583. æC 
  14584. Trap macro    _OpenRFDeny
  14585.  
  14586. Parameter block
  14587.   -->    12    ioCompletion  long    optional completion routine ptr
  14588.   <--    16    ioResult      word    error result code
  14589.   -->    18    ioFileName    long    ptr to pathname
  14590.   -->    22    ioVRefNum     word    vol identifier
  14591.   <--    24    ioRefNum      word    file refNum
  14592.   -->    26    ioDenyModes   word    access rights data
  14593.   -->    48    ioDirID       long    directory ID
  14594.  
  14595. PBHOpenRFDeny opens a file’s resource fork under specific access rights.
  14596. It creates an access path to the file having the name pointed to by
  14597. ioFileName/ioDirID.  The path reference number is returned in ioRefNum.  The format
  14598. of the access rights data contained in ioDenyModes is described under the OpenDeny
  14599. call.
  14600.  
  14601. A fnfErr is returned if the input specification does not point to an existing file. 
  14602. A permErr is returned if the file is already open and you cannot open it under the
  14603. deny modes that you have specified.  An opWrErr is returned if you have asked for
  14604. write permission and the file is already opened by you for write.  The already-opened
  14605. path reference number is returned in ioRefNum.  An AccessDenied error is returned if
  14606. you do not have the right to access the file.
  14607.  
  14608. æKY PBHRename
  14609. æFp Files.p
  14610. æT FUNCTION
  14611. æD FUNCTION PBHRename(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14612. æDT myVariable := PBHRename(paramBlock,async);
  14613. æRI PBHRename function IV-154 
  14614. æC 
  14615. Trap macro    _HRename
  14616.  
  14617. Parameter block
  14618.   -->    12    ioCompletion  pointer
  14619.   <--    16    ioResult      word
  14620.   -->    18    ioNamePtr     pointer
  14621.   -->    22    ioVRefNum     word
  14622.   -->    28    ioMisc        pointer
  14623.   -->    48    ioDirID       long word
  14624.  
  14625. PBHRename is identical to PBRename except that it accepts a directory ID in ioDirID
  14626. and can be used to rename directories as well as files and volumes. Given a pointer
  14627. to the name of a file or directory in ioNamePtr, PBHRename changes it to the name
  14628. pointed to by ioMisc. Given a pointer to a volume name in ioNamePtr or a volume
  14629. reference number in ioVRefNum, it changes the name of the volume to the name pointed
  14630. to by ioMisc.
  14631.  
  14632. Warning:  PBHRename cannot be used to change the directory a file is in.
  14633.  
  14634. Result codes    noErr      No error
  14635.                 bdNamErr   Bad file name
  14636.                 dirFulErr  File directory full
  14637.                 dirNFErr   Directory not found or incomplete pathname
  14638.                 dupFNErr   Duplicate file name and version
  14639.                 extFSErr   External file system
  14640.                 fLckdErr   File locked
  14641.                 fnfErr     File not found
  14642.                 fsRnErr    Problem during rename
  14643.                 ioErr      I/O error
  14644.                 nsvErr     No such volume
  14645.                 paramErr   No default volume
  14646.                 vLckdErr   Software volume lock
  14647.                 wPrErr     Hardware volume lock
  14648.  
  14649. æKY PBHRstFLock
  14650. æFp Files.p
  14651. æT FUNCTION
  14652. æD FUNCTION PBHRstFLock(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14653. æDT myVariable := PBHRstFLock(paramBlock,async);
  14654. æRI PBHRstFLock function IV-152 
  14655. æC 
  14656. Trap macro    _HRstFLock
  14657.  
  14658. Parameter block
  14659.   -->    12    ioCompletion  pointer
  14660.   <--    16    ioResult      word
  14661.   -->    18    ioNamePtr     pointer
  14662.   -->    22    ioVRefNum     word
  14663.   -->    48    ioDirID       long word
  14664.  
  14665. PBHRstFLock is identical to PBRstFLock except that it accepts a directory ID in
  14666. ioDirID.
  14667.  
  14668. Result codes    noErr     No error
  14669.                 dirNFErr  Directory not found or incomplete pathname
  14670.                 extFSErr  External file system
  14671.                 fnfErr    File not found
  14672.                 ioErr     I/O error
  14673.                 nsvErr    No such volume
  14674.                 vLckdErr  Software volume lock
  14675.                 wPrErr    Hardware volume lock
  14676.     
  14677. æKY PBHSetDirAccess
  14678. æFp Files.p
  14679. æT FUNCTION
  14680. æD FUNCTION PBHSetDirAccess(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14681. æDT myVariable := PBHSetDirAccess(paramBlock,async);
  14682. æRI PBHSetDirAccess function  V-394
  14683. æC 
  14684. Trap macro    _SetDirAccess
  14685.  
  14686. Parameter block
  14687.   -->    12    ioCompletion  long    optional completion routine ptr
  14688.   <--    16    ioResult      word    error result code
  14689.   -->    18    ioFileName    long    pathname identifier
  14690.   -->    22    ioVRefNum     word    volume refNum
  14691.   -->    36    ioACOwnerID   long    owner ID
  14692.   -->    40    ioACGroupID   long    group ID
  14693.   -->    44    ioACAccess    long    access rights
  14694.   -->    48    ioDirID       long    directory ID
  14695.  
  14696. PBHSetDirAccess allows you to change the access rights to a folder pointed to by the
  14697. ioFileName/ioDirID pair.  IOACOwnerID contains the new owner ID.  IOACGroupID contains
  14698. the group ID.  IOACAccess contains the folder’s access rights.  You cannot set the
  14699. owner bit or the user’s rights of the directory.  To change the owner or group, you
  14700. should set the ioACOwnerID or ioACGroupID field with the appropriate ID of the new
  14701. owner/group.  You must be the owner of the directory to change the owner or group
  14702. ID.
  14703.  
  14704. A fnfErr is returned if the pathname does not point to a valid directory.  An AccessDenied
  14705. error is returned if you do not have the correct access rights to modify the parameters
  14706. for this directory.  A paramErr is returned if you try to set the owner bit or user’s
  14707. rights bits.
  14708.  
  14709. æKY PBHSetFInfo
  14710. æFp Files.p
  14711. æT FUNCTION
  14712. æD FUNCTION PBHSetFInfo(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14713. æDT myVariable := PBHSetFInfo(paramBlock,async);
  14714. æRI PBHSetFInfo function IV-150
  14715. æC 
  14716. Trap macro    _HSetFileInfo
  14717.  
  14718. Parameter block
  14719.   -->    12    ioCompletion  pointer
  14720.   <--    16    ioResult      word
  14721.   -->    18    ioNamePtr     pointer
  14722.   -->    22    ioVRefNum     word
  14723.   -->    32    ioFlFndrInfo  16 bytes
  14724.   -->    48    ioDirID       long word
  14725.   -->    72    ioFlCrDat     long word
  14726.   -->    76    ioFlMdDat     long word
  14727.  
  14728. PBHSetFInfo is identical to PBSetFInfo except that it accepts a directory ID in
  14729. ioDirID.
  14730.  
  14731. Result codes    noErr     No error
  14732.                 bdNamErr  Bad file name
  14733.                 dirNFErr  Directory not found or incomplete pathname
  14734.                 extFSErr  External file system
  14735.                 fLckdErr  File locked
  14736.                 fnfErr    File not found
  14737.                 ioErr     I/O error
  14738.                 nsvErr    No such volume
  14739.                 vLckdErr  Software volume lock
  14740.                 wPrErr    Hardware volume lock
  14741.  
  14742. æKY PBHSetFLock
  14743. æFp Files.p
  14744. æT FUNCTION
  14745. æD FUNCTION PBHSetFLock(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  14746. æDT myVariable := PBHSetFLock(paramBlock,async);
  14747. æRI PBHSetFLock function IV-151
  14748. æC 
  14749. Trap macro    _HSetFLock
  14750.  
  14751. Parameter block
  14752.   -->    12    ioCompletion  pointer
  14753.   <--    16    ioResult      word
  14754.   -->    18    ioNamePtr     pointer
  14755.   -->    22    ioVRefNum     word
  14756.   -->    48    ioDirID       long word
  14757.  
  14758. PBHSetFLock is identical to PBSetFLock except that it accepts a directory ID in
  14759. ioDirID.
  14760.  
  14761. Result codes    noErr     No error
  14762.                 dirNFErr  Directory not found or incomplete pathname
  14763.                 extFSErr  External file system
  14764.                 fnfErr    File not found
  14765.                 ioErr     I/O error
  14766.                 nsvErr    No such volume
  14767.                 vLckdErr  Software volume lock
  14768.                 wPrErr    Hardware volume lock
  14769.  
  14770. æKY PBHSetVol
  14771. æFp Files.p
  14772. æT FUNCTION
  14773. æD FUNCTION PBHSetVol(paramBlock: WDPBPtr;async: BOOLEAN): OSErr;
  14774. æDT myVariable := PBHSetVol(paramBlock,async);
  14775. æRT 140
  14776. æRI PBHSetVol function  IV-133, N140
  14777. æC 
  14778. •••Refer to Technical Note #140:•••
  14779.  
  14780. Trap macro    _HSetVol
  14781.  
  14782. Parameter block
  14783.   -->    12    ioCompletion  pointer
  14784.   <--    16    ioResult      word
  14785.   -->    18    ioNamePtr     pointer
  14786.   -->    22    ioVRefNum     word
  14787.   -->    48    ioWDDirID     long word
  14788.  
  14789. PBHSetVol sets both the default volume and the default directory. The default directory
  14790. to be used can be specified by either a volume reference number or a working directory
  14791. reference number in ioVRefNum, a directory ID in ioWDDirID, or a pointer to a pathname
  14792. (possibly NIL) in ioNamePtr.
  14793.  
  14794. Note:  Both the default volume and the default directory are used in
  14795.        calls made with no volume name and a volume reference number of zero.
  14796.  
  14797. Result codes    noErr     No error
  14798.                 nsvErr    No default volume
  14799.  
  14800. æKY PBLockRange
  14801. æFp Files.p
  14802. æT FUNCTION
  14803. æD FUNCTION PBLockRange(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  14804. æDT myVariable := PBLockRange(paramBlock,async);
  14805. æRT 186
  14806. æRI PBLockRange function  IV-138
  14807. æC 
  14808. •••Refer to Technical Note #186:•••
  14809.  
  14810. Trap macro    _LockRng
  14811.  
  14812. Parameter block
  14813.   -->    12    ioCompletion  pointer
  14814.   <--    16    ioResult      word
  14815.   -->    24    ioRefNum      word
  14816.   -->    36    ioReqCount    long word
  14817.   -->    44    ioPosMode     word
  14818.   -->    46    ioPosOffset   long word
  14819.  
  14820. On a file opened with a shared read/write permission, PBLockRange is used in conjunction
  14821. with PBRead and PBWrite to lock a certain portion of the file. PBLockRange uses the
  14822. same parameters as both PBRead and PBWrite; by calling it immediately before PBRead,
  14823. you can use the information present in the parameter block for the PBRead call.
  14824.  
  14825. When you’re finished with the data (typically after a call to PBWrite), be sure to
  14826. call PBUnlockRange to free up that portion of the file for subsequent PBRead calls.
  14827.  
  14828. Warning:  PBLockRange operates only with the hierarchical version of the
  14829.           File Manager; if used on a Macintosh equipped only with the 64K
  14830.           ROM version of the File Manager, it will generate a system error.
  14831.  
  14832. Result codes    noErr     No error
  14833.                 eofErr    End-of-file
  14834.                 extFSErr  External file system
  14835.                 fnOpnErr  File not open
  14836.                 ioErr     I/O error
  14837.                 paramErr  Negative ioReqCount
  14838.                 rfNumErr  Bad reference number
  14839.  
  14840. æKY PBMountVol
  14841. æFp Files.p
  14842. æT FUNCTION
  14843. æTN $A00F
  14844. æD FUNCTION PBMountVol(paramBlock: ParmBlkPtr): OSErr;
  14845. æDT myVariable := PBMountVol(paramBlock);
  14846. æMM 
  14847. æRT 134
  14848. æRI PBMountVol function II-103, IV-128
  14849. æC 
  14850. »Accessing Volumes
  14851.  
  14852. To get the volume reference number of a volume, given the path reference number of a
  14853. file on that volume, both Pascal and assembly-language programmers can call the
  14854. high-level File Manager function GetVRefNum. Assembly-language programmers may prefer
  14855. calling the function GetFCBInfo (described below in the section “Data Structures in
  14856. Memory”).
  14857.  
  14858. FUNCTION PBMountVol (paramBlock:  ParmBlkPtr) :  OSErr;
  14859.  
  14860. Trap macro    _MountVol
  14861.  
  14862. Parameter block
  14863.   <--    16    ioResult   word
  14864.   <->    22    ioVRefNum  word
  14865.  
  14866. PBMountVol mounts the volume in the drive specified by ioVRefNum, and returns a
  14867. volume reference number in ioVRefNum. If there are no volumes already mounted, this
  14868. volume becomes the default volume. PBMountVol is always executed synchronously.
  14869.  
  14870. Note:  When mounting hierarchical volumes, PBMountVol opens two files
  14871.        needed for maintaining file directory and file mapping information.
  14872.        PBMountVol can fail if there are no access paths available for these
  14873.        two files; it will return tmfoErr as its function result.
  14874.  
  14875. Result codes    noErr        No error
  14876.                 badMDBErr    Bad master directory block
  14877.                 extFSErr     External file system
  14878.                 ioErr        I/O error
  14879.                 memFullErr   Not enough room in heap zone
  14880.                 noMacDskErr  Not a Macintosh disk
  14881.                 nsDrvErr     No such drive
  14882.                 paramErr     Bad drive number
  14883.                 tmfoErr      Too many files open
  14884.                 volOnLinErr  Volume already on-line
  14885.  
  14886. æKY PBOffLine
  14887. æFp Files.p
  14888. æT FUNCTION
  14889. æTN $A035
  14890. æD FUNCTION PBOffLine(paramBlock: ParmBlkPtr): OSErr;
  14891. æDT myVariable := PBOffLine(paramBlock);
  14892. æMM   
  14893. æRI PBOffLine function II-106, IV-134
  14894. æC 
  14895. Trap macro    _OffLine
  14896.  
  14897. Parameter block
  14898.   -->    12    ioCompletion  pointer
  14899.   <--    16    ioResult      word
  14900.   -->    18    ioNamePtr     pointer
  14901.   -->    22    ioVRefNum     word
  14902.  
  14903. PBOffLine places off-line the volume specified by ioNamePtr or ioVRefNum, by calling
  14904. PBFlushVol to flush the volume and releasing all the memory used for the volume
  14905. except for the volume control block. PBOffLine is always executed synchronously.
  14906.  
  14907. Result codes    noErr     No error
  14908.                 bdNamErr  Bad volume name
  14909.                 extFSErr  External file system
  14910.                 ioErr     I/O error
  14911.                 nsDrvErr  No such drive
  14912.                 nsvErr    No such volume
  14913.                 paramErr  No default volume
  14914.  
  14915. æKY PBOpen
  14916. æFp Files.p
  14917. æT FUNCTION
  14918. æTN $A000
  14919. æD FUNCTION PBOpen(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  14920. æDT myVariable := PBOpen(paramBlock,async);
  14921. æRI PBOpen function  IV-135  Device Manager II-184  File Manager II-108
  14922. æC 
  14923. Trap macro    _Open
  14924.  
  14925. Parameter block
  14926.   -->    12    ioCompletion  pointer
  14927.   <--    16    ioResult      word
  14928.   -->    18    ioNamePtr     pointer
  14929.   -->    22    ioVRefNum     word
  14930.   <--    24    ioRefNum      word
  14931.   -->    26    ioVersNum     byte
  14932.   -->    27    ioPermssn     byte
  14933.   -->    28    ioMisc        pointer
  14934.  
  14935. PBOpen creates an access path to the file having the name pointed to by ioNamePtr
  14936. (and on flat volumes, the version number ioVersNum) on the volume specified by ioVRefNum.
  14937. A path reference number is returned in ioRefNum.
  14938.  
  14939. IOMisc either points to a portion of memory (522 bytes) to be used as the access
  14940. path’s buffer, or is NIL if you want the volume buffer to be used instead.
  14941.  
  14942. Warning:  All access paths to a single file that’s opened multiple times
  14943.           should share the same buffer so that they will read and write
  14944.           the same data.
  14945.  
  14946. IOPermssn specifies the path’s read/write permission. A path can be opened for writing
  14947. even if it accesses a file on a locked volume, and an error won’t be returned until a
  14948. PBWrite, PBSetEOF, or PBAllocate call is made.
  14949.  
  14950. If you attempt to open a locked file for writing, PBOpen will return permErr as its
  14951. function result. If you request exclusive read/write permission but another access
  14952. path already has write permission (whether write only, exclusive
  14953. read/write, or shared read/write), PBOpen will return the reference number of the
  14954. existing access path in ioRefNum and opWrErr as its function result. Similarly, if
  14955. you request shared read/write permission but another access path already has exclusive
  14956. read/write permission, PBOpen will return the reference number of the access path in
  14957. ioRefNum and opWrErr as its function result.
  14958.  
  14959. Result codes    noErr     No error
  14960.                 bdNamErr  Bad file name
  14961.                 extFSErr  External file system
  14962.                 fnfErr    File not found
  14963.                 ioErr     I/O error
  14964.                 nsvErr    No such volume
  14965.                 opWrErr   File already open for writing
  14966.                 permErr   Attempt to open locked file for writing
  14967.                 tmfoErr   Too many files open
  14968.  
  14969. æKY PBOpenFile
  14970. æFp Files.p
  14971. æT FUNCTION
  14972. æD FUNCTION PBOpenFile(paramBlock: ParmBlkPtr): OSErr;
  14973. æDT myVariable := PBOpenFile(paramBlock);
  14974.  
  14975. æKY PBOpenRF
  14976. æFp Files.p
  14977. æT FUNCTION
  14978. æTN $A00A
  14979. æD FUNCTION PBOpenRF(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  14980. æDT myVariable := PBOpenRF(paramBlock,async);
  14981. æMM 
  14982. æRT 74
  14983. æRI PBOpenRF function II-109, IV-137 
  14984. æC 
  14985. Trap macro    _OpenRF
  14986.  
  14987. Parameter block
  14988.   -->    12    ioCompletion  pointer
  14989.   <--    16    ioResult      word
  14990.   -->    18    ioNamePtr     pointer
  14991.   -->    22    ioVRefNum     word
  14992.   <--    24    ioRefNum      word
  14993.   -->    26    ioVersNum     byte
  14994.   -->    27    ioPermssn     byte
  14995.   -->    28    ioMisc        pointer
  14996.  
  14997. PBOpenRF is identical to PBOpen, except that it opens the file’s resource fork instead
  14998. of its data fork.
  14999.  
  15000. Note:  Normally you should access a file’s resource fork through the
  15001.        routines of the Resource Manager rather than the File Manager.
  15002.        PBOpenRF doesn’t read the resource map into memory; it’s really
  15003.        only useful for block-level operations such as copying files.
  15004.  
  15005. Result codes    noErr     No error
  15006.                 bdNamErr  Bad file name
  15007.                 extFSErr  External file system
  15008.                 fnfErr    File not found
  15009.                 ioErr     I/O error
  15010.                 nsvErr    No such volume
  15011.                 opWrErr   File already open for writing
  15012.                 permErr   Attempt to open locked file for writing
  15013.                 tmfoErr   Too many files open
  15014.  
  15015. æKY PBOpenWD
  15016. æFp Files.p
  15017. æT FUNCTION
  15018. æD FUNCTION PBOpenWD(paramBlock: WDPBPtr;async: BOOLEAN): OSErr;
  15019. æDT myVariable := PBOpenWD(paramBlock,async);
  15020. æRT 77, 190
  15021. æRI PBOpenWD function  IV-158, N77-1
  15022. æC 
  15023. Trap macro    _OpenWD
  15024.  
  15025. Parameter block
  15026.   -->    12    ioCompletion  pointer
  15027.   <--    16    ioResult      word
  15028.   -->    18    ioNamePtr     pointer
  15029.   <->    22    ioVRefNum     word
  15030.   -->    28    ioWDProcID    long word
  15031.   -->    48    ioWDDirID     long word
  15032.  
  15033. PBOpenWD takes the directory specified by ioVRefNum, ioWDDirID, and ioWDProcID and
  15034. makes it a working directory. (You can also specify the directory using a combination
  15035. of partial pathname and directory ID.) It returns a working directory reference
  15036. number in ioVRefNum that can be used in subsequent calls.
  15037.  
  15038. If a given directory has already been made a working directory using the same ioWDProcID,
  15039. no new working directory will be opened; instead, the existing working directory
  15040. reference number will be returned. If a given directory was already made a working
  15041. directory using a different ioWDProcID, a new working directory reference number is
  15042. returned.
  15043.  
  15044. Result codes    noErr       No error
  15045.                 tmwdoErr    Too many working directories open
  15046.  
  15047. æKY PBRead
  15048. æFp Files.p
  15049. æT FUNCTION
  15050. æTN $A002
  15051. æD FUNCTION PBRead(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15052. æDT myVariable := PBRead(paramBlock,async);
  15053. æRT 187
  15054. æRI PBRead function  IV-139  Device Manager II-185  File Manager II-110
  15055. æC  
  15056. Trap macro    _Read
  15057.  
  15058. Parameter block
  15059.   -->    12    ioCompletion  pointer
  15060.   <--    16    ioResult      word
  15061.   -->    24    ioRefNum      word
  15062.   -->    32    ioBuffer      pointer
  15063.   -->    36    ioReqCount    long word
  15064.   <--    40    ioActCount    long word
  15065.   -->    44    ioPosMode     word
  15066.   <->    46    ioPosOffset   long word
  15067.  
  15068. PBRead attempts to read ioReqCount bytes from the open file whose access path is
  15069. specified by ioRefNum, and transfer them to the data buffer pointed to by ioBuffer.
  15070. The position of the mark is specified by ioPosMode and ioPosOffset. If you try to
  15071. read past the logical end-of-file, PBRead moves the mark to the end-of-file and
  15072. returns eofErr as its function result. After the read is completed, the mark is
  15073. returned in ioPosOffset and the number of bytes actually read is returned in ioActCount.
  15074.  
  15075. Result codes    noErr     No error
  15076.                 eofErr    End-of-file
  15077.                 extFSErr  External file system
  15078.                 fnOpnErr  File not open
  15079.                 ioErr     I/O error
  15080.                 paramErr  Negative ioReqCount
  15081.                 rfNumErr  Bad reference number
  15082.  
  15083. æKY PBRename
  15084. æFp Files.p
  15085. æT FUNCTION
  15086. æTN $A00B
  15087. æD FUNCTION PBRename(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15088. æDT myVariable := PBRename(paramBlock,async);
  15089. æRI PBRename function II-118, IV-153
  15090. æC 
  15091. Trap macro    _Rename
  15092.  
  15093. Parameter block
  15094.   -->    12    ioCompletion  pointer
  15095.   <--    16    ioResult      word
  15096.   -->    18    ioNamePtr     pointer
  15097.   -->    22    ioVRefNum     word
  15098.   -->    26    ioVersNum     byte
  15099.   -->    28    ioMisc        pointer
  15100.  
  15101. Given a pointer to a file name in ioNamePtr (and on flat volumes, a version number in
  15102. ioVersNum), PBRename changes the name of the file to the name pointed to by ioMisc.
  15103. (If the name pointed to by ioNamePtr contains one or more colons, so must the name
  15104. pointed to by ioMisc.) Access paths currently in use aren’t affected. Given a pointer
  15105. to a volume name in ioNamePtr or a volume reference number in ioVRefNum, it changes
  15106. the name of the volume to the name pointed to by ioMisc. If a volume to be renamed is
  15107. specified by its volume reference number, ioNamePtr can be NIL.
  15108.  
  15109. Warning:  If a volume to be renamed is specified by its volume name, be
  15110.           sure that it ends with a colon, or Rename will consider it a
  15111.           file name.
  15112.  
  15113. Result codes    noErr      No error
  15114.                 bdNamErr   Bad file name
  15115.                 dirFulErr  File directory full
  15116.                 dupFNErr   Duplicate file name and version
  15117.                 extFSErr   External file system
  15118.                 fLckdErr   File locked
  15119.                 fnfErr     File not found
  15120.                 fsRnErr    Problem during rename
  15121.                 ioErr      I/O error
  15122.                 nsvErr     No such volume
  15123.                 paramErr   No default volume
  15124.                 vLckdErr   Software volume lock
  15125.                 wPrErr     Hardware volume lock
  15126.  
  15127. æKY PBRstFLock
  15128. æFp Files.p
  15129. æT FUNCTION
  15130. æTN $A042
  15131. æD FUNCTION PBRstFLock(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15132. æDT myVariable := PBRstFLock(paramBlock,async);
  15133. æRI PBRstFLock function II-117, IV-152
  15134. æC 
  15135. Trap macro    _RstFilLock
  15136.  
  15137. Parameter block
  15138.   -->    12    ioCompletion  pointer
  15139.   <--    16    ioResult      word
  15140.   -->    18    ioNamePtr     pointer
  15141.   -->    22    ioVRefNum     word
  15142.   -->    26    ioFVersNum    byte
  15143.  
  15144. PBRstFLock unlocks the file having the name pointed to by ioNamePtr (and on flat
  15145. volumes, the version number ioFVersNum) on the volume specified by ioVRefNum. Access
  15146. paths currently in use aren’t affected.
  15147.  
  15148. Result codes    noErr     No error
  15149.                 extFSErr  External file system
  15150.                 fnfErr    File not found
  15151.                 ioErr     I/O error
  15152.                 nsvErr    No such volume
  15153.                 vLckdErr  Software volume lock
  15154.                 wPrErr    Hardware volume lock
  15155.  
  15156. æKY PBSetCatInfo
  15157. æFp Files.p
  15158. æT FUNCTION
  15159. æD FUNCTION PBSetCatInfo(paramBlock: CInfoPBPtr;async: BOOLEAN): OSErr;
  15160. æDT myVariable := PBSetCatInfo(paramBlock,async);
  15161. æRI PBSetCatInfo function  IV-156
  15162. æC 
  15163. Trap macro    _SetCatInfo
  15164.  
  15165. Parameter block
  15166.  
  15167.   Files:                                  Directories:
  15168.   -->    12    ioCompletion  pointer      -->    12    ioCompletion  pointer
  15169.   <--    16    ioResult      word         <--    16    ioResult      word
  15170.   <->    18    ioNamePtr     pointer      <->    18    ioNamePtr     pointer
  15171.   -->    22    ioVRefNum     word         -->    22    ioVRefNum     word
  15172.   -->    30    ioFlAttrib    byte         -->    30    ioFlAttrib    byte
  15173.   -->    32    ioFlFndrInfo  16 bytes     -->    32    ioDrUsrWds    16 bytes
  15174.   -->    48    ioDirID       long word    -->    48    ioDrDirID     long word
  15175.   -->    72    ioFlCrDat     long word    -->    72    ioDrCrDat     long word
  15176.   -->    76    ioFlMdDat     long word    -->    76    ioDrMdDat     long word
  15177.   -->    80    ioFlBkDat     long word    -->    80    ioDrBkDat     long word
  15178.   -->    84    ioFlXFndrInfo 16 bytes     -->    84    ioDrFndrInfo  16 bytes
  15179.   -->    104   ioFlClpSiz    long word
  15180.  
  15181. PBSetCatInfo sets information about the files and directories in a catalog. With
  15182. files, it’s similar to PBHSetFileInfo but lets you set some additional information.
  15183. The information that can be set for files is shown in the left column, and the corresponding
  15184. information for directories is shown in the right column.
  15185.  
  15186. Result codes    noErr     No error
  15187.                 bdNamErr  Bad file name
  15188.                 dirNFErr  Directory not found or incomplete pathname
  15189.                 extFSErr  External file system
  15190.                 fnfErr    File not found
  15191.                 ioErr     I/O error
  15192.                 nsvErr    No such volume
  15193.                 paramErr  No default volume
  15194.  
  15195. æKY PBSetEOF
  15196. æFp Files.p
  15197. æT FUNCTION
  15198. æTN $A012
  15199. æD FUNCTION PBSetEOF(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15200. æDT myVariable := PBSetEOF(paramBlock,async);
  15201. æRI PBSetEOF function II-112, IV-142
  15202. æC 
  15203. Trap macro    _SetEOF
  15204.  
  15205. Parameter block
  15206.   -->    12    ioCompletion  pointer
  15207.   <--    16    ioResult      word
  15208.   -->    24    ioRefNum      word
  15209.   -->    28    ioMisc        long word
  15210.  
  15211. PBSetEOF sets the logical end-of-file of the open file, whose access path is specified
  15212. by ioRefNum, to ioMisc. If you attempt to set the logical end-of-file beyond the
  15213. physical end-of-file, another allocation block is added to the file; if there isn’t
  15214. enough space on the volume, no change is made, and PBSetEOF returns dskFulErr as its
  15215. function result. If ioMisc is 0, all space occupied by the file on the volume is
  15216. released.
  15217.  
  15218. Result codes    noErr      No error
  15219.                 dskFulErr  Disk full
  15220.                 extFSErr   External file system
  15221.                 fLckdErr   File locked
  15222.                 fnOpnErr   File not open
  15223.                 ioErr      I/O error
  15224.                 rfNumErr   Bad reference number
  15225.                 vLckdErr   Software volume lock
  15226.                 wPrErr     Hardware volume lock
  15227.                 wrPermErr  Read/write permission doesn’t allow writing
  15228.  
  15229. æKY PBSetFInfo
  15230. æFp Files.p
  15231. æT FUNCTION
  15232. æTN $A00D
  15233. æD FUNCTION PBSetFInfo(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15234. æDT myVariable := PBSetFInfo(paramBlock,async);
  15235. æRI PBSetFInfo function II-116, IV-150
  15236. æC 
  15237. Trap macro    _SetFileInfo
  15238.  
  15239. Parameter block
  15240.   -->    12    ioCompletion  pointer
  15241.   <--    16    ioResult      word
  15242.   -->    18    ioNamePtr     pointer
  15243.   -->    22    ioVRefNum     word
  15244.   -->    26    ioFVersNum    byte
  15245.   -->    32    ioFlFndrInfo  16 bytes
  15246.   -->    72    ioFlCrDat     long word
  15247.   -->    76    ioFlMdDat     long word
  15248.  
  15249. PBSetFInfo sets information (including the date and time of creation and modification,
  15250. and information needed by the Finder) about the file having the name pointed to by
  15251. ioNamePtr (and on flat volumes, the version number ioFVersNum) on the volume specified
  15252. by ioVRefNum. You should call PBGetFInfo just before PBSetFInfo, so the current
  15253. information is present in the parameter block.
  15254.  
  15255. Result codes    noErr     No error
  15256.                 bdNamErr  Bad file name
  15257.                 extFSErr  External file system
  15258.                 fLckdErr  File locked
  15259.                 fnfErr    File not found
  15260.                 ioErr     I/O error
  15261.                 nsvErr    No such volume
  15262.                 vLckdErr  Software volume lock
  15263.                 wPrErr    Hardware volume lock
  15264.  
  15265. æKY PBSetFLock
  15266. æFp Files.p
  15267. æT FUNCTION
  15268. æTN $A041
  15269. æD FUNCTION PBSetFLock(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15270. æDT myVariable := PBSetFLock(paramBlock,async);
  15271. æRI PBSetFLock function II-116, IV-151
  15272. æC 
  15273. Trap macro    _SetFilLock
  15274.  
  15275. Parameter block
  15276.   -->    12    ioCompletion  pointer
  15277.   <--    16    ioResult      word
  15278.   -->    18    ioNamePtr     pointer
  15279.   -->    22    ioVRefNum     word
  15280.   -->    26    ioFVersNum    byte
  15281.  
  15282. PBSetFLock locks the file having the name pointed to by ioNamePtr (and on flat volumes,
  15283. the version number ioFVersNum) on the volume specified by ioVRefNum. Access paths
  15284. currently in use aren’t affected.
  15285.  
  15286. Result codes    noErr     No error
  15287.                 extFSErr  External file system
  15288.                 fnfErr    File not found
  15289.                 ioErr     I/O error
  15290.                 nsvErr    No such volume
  15291.                 vLckdErr  Software volume lock
  15292.                 wPrErr    Hardware volume lock
  15293.  
  15294. æKY PBSetFPos
  15295. æFp Files.p
  15296. æT FUNCTION
  15297. æTN $A044
  15298. æD FUNCTION PBSetFPos(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15299. æDT myVariable := PBSetFPos(paramBlock,async);
  15300. æRI PBSetFPos function II-111, IV-141
  15301. æC 
  15302. Trap macro    _SetFPos
  15303.  
  15304. Parameter block
  15305.   -->    12    ioCompletion  pointer
  15306.   <--    16    ioResult      word
  15307.   -->    24    ioRefNum      word
  15308.   -->    44    ioPosMode     word
  15309.   <->    46    ioPosOffset   long word
  15310.  
  15311. PBSetFPos sets the mark of the open file whose access path is specified by ioRefNum
  15312. to the position specified by ioPosMode and ioPosOffset. The position at which the
  15313. mark is actually set is returned in ioPosOffset. If you try to set the mark past the
  15314. logical end-of-file, PBSetFPos moves the mark to the end-of-file and returns eofErr
  15315. as its function result.
  15316.  
  15317. Result codes    noErr     No error
  15318.                 eofErr    End-of-file
  15319.                 extFSErr  External file system
  15320.                 fnOpnErr  File not open
  15321.                 ioErr     I/O error
  15322.                 posErr    Attempt to position before start of file
  15323.                 rfNumErr  Bad reference number
  15324.  
  15325. æKY PBSetFVers
  15326. æFp Files.p
  15327. æT FUNCTION
  15328. æTN $A043
  15329. æD FUNCTION PBSetFVers(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15330. æDT myVariable := PBSetFVers(paramBlock,async);
  15331. æRI PBSetFVers function II-117, IV-153
  15332. æC 
  15333. Trap macro    _SetFilType
  15334.  
  15335. Parameter block
  15336.   -->    12    ioCompletion  pointer
  15337.   <--    16    ioResult      word
  15338.   -->    18    ioNamePtr     pointer
  15339.   -->    22    ioVRefNum     word
  15340.   -->    26    ioVersNum     byte
  15341.   -->    28    ioMisc        byte
  15342.  
  15343. PBSetFVers has no effect on hierarchical volumes. On flat volumes, PBSetFVers changes
  15344. the version number of the file having the name pointed to by ioNamePtr and version
  15345. number ioVersNum, on the volume specified by ioVRefNum, to the version number stored
  15346. in the high-order byte of ioMisc. Access paths currently in use aren’t affected.
  15347.  
  15348. Result codes    noErr         No error
  15349.                 bdNamErr      Bad file name
  15350.                 dupFNErr      Duplicate file name and version
  15351.                 extFSErr      External file system
  15352.                 fLckdErr      File locked
  15353.                 fnfErr        File not found
  15354.                 nsvErr        No such volume
  15355.                 ioErr         I/O error
  15356.                 paramErr      No default volume
  15357.                 vLckdErr      Software volume lock
  15358.                 wPrErr        Hardware volume lock
  15359.                 wrgVolTypErr  Attempt to perform hierarchical operation
  15360.                               on a flat volume
  15361.     
  15362. æKY PBSetVInfo
  15363. æFp Files.p
  15364. æT FUNCTION
  15365. æD FUNCTION PBSetVInfo(paramBlock: HParmBlkPtr;async: BOOLEAN): OSErr;
  15366. æDT myVariable := PBSetVInfo(paramBlock,async);
  15367. æRT 204
  15368. æRI PBSetVInfo function  IV-131
  15369. æC 
  15370. •••Refer to Technical Note #204:•••
  15371.  
  15372. Trap macro    _SetVolInfo
  15373.  
  15374. Parameter block
  15375.   -->    12    ioCompletion  pointer
  15376.   <--    16    ioResult      word
  15377.   -->    18    ioNamePtr     pointer
  15378.   -->    22    ioVRefNum     word
  15379.   -->    30    ioVCrDate     long word
  15380.   -->    34    ioVLsMod      long word
  15381.   -->    38    ioVAtrb       word
  15382.   -->    52    ioVClpSiz     long word
  15383.   -->    72    ioVBkUp       long word
  15384.   -->    76    ioVSeqNum     word
  15385.   -->    90    ioVFndrInfo   32 bytes
  15386.  
  15387. PBSetVInfo lets you modify information about volumes. A pointer to a new name for the
  15388. volume can be specified in ioNamePtr. The date and time of the volume’s creation and
  15389. modification can be set with ioVCrDate and ioVLsMod respectively. Only bit 15 of
  15390. ioVAtrb can be changed; setting it locks the volume.
  15391.  
  15392. Note:  The volume cannot be specified by name; you must use either the
  15393.        volume reference number or the drive number.
  15394.  
  15395. Warning:  PBSetVInfo operates only with the hierarchical version of the
  15396.           File Manager; if used on a Macintosh equipped only with the
  15397.           64K ROM version of the File Manager, it will generate a system error.
  15398.  
  15399. Result codes    noErr       No error
  15400.                 nsvErr      No such volume
  15401.                 paramErr    No default volume
  15402.  
  15403. æKY PBSetVol
  15404. æFp Files.p
  15405. æT FUNCTION
  15406. æTN $A015
  15407. æD FUNCTION PBSetVol(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15408. æDT myVariable := PBSetVol(paramBlock,async);
  15409. æRI PBSetVol function II-105,  IV-132
  15410. æC 
  15411. Trap macro    _SetVol
  15412.  
  15413. Parameter block
  15414.   -->    12    ioCompletion  pointer
  15415.   <--    16    ioResult      word
  15416.   -->    18    ioNamePtr     pointer
  15417.   -->    22    ioVRefNum     word
  15418.  
  15419. PBSetVol sets the default volume to the mounted volume specified by ioNamePtr or
  15420. ioVRefNum. On hierarchical volumes, PBSetVol also sets the root directory as the
  15421. default directory.
  15422.  
  15423. Result codes    noErr     No error
  15424.                 bdNamErr  Bad volume name
  15425.                 nsvErr    No such volume
  15426.                 paramErr  No default volume
  15427.  
  15428. æKY PBUnlockRange
  15429. æFp Files.p
  15430. æT FUNCTION
  15431. æD FUNCTION PBUnlockRange(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15432. æDT myVariable := PBUnlockRange(paramBlock,async);
  15433. æRT 186
  15434. æRI PBUnlockRange function  IV-139
  15435. æC 
  15436. Trap macro    _UnlockRng
  15437.  
  15438. Parameter block
  15439.   -->    12    ioCompletion  pointer
  15440.   <--    16    ioResult      word
  15441.   -->    24    ioRefNum      word
  15442.   -->    36    ioReqCount    long word
  15443.   -->    44    ioPosMode     word
  15444.   -->    46    ioPosOffset   long word
  15445.  
  15446. PBUnlockRange is used in conjunction with PBRead and PBWrite to unlock a certain
  15447. portion of a file that you locked with PBLockRange.
  15448.  
  15449. Warning:  PBUnlockRange operates only with the hierarchical version of
  15450.           the File Manager; if used on a Macintosh equipped only with
  15451.           the 64K ROM version of the File Manager, it will generate a
  15452.           system error.
  15453.  
  15454. Result codes    noErr     No error
  15455.                 eofErr    End-of-file
  15456.                 extFSErr  External file system
  15457.                 fnOpnErr  File not open
  15458.                 ioErr     I/O error
  15459.                 paramErr  Negative ioReqCount
  15460.                 rfNumErr  Bad reference number
  15461.  
  15462. æKY PBUnmountVol
  15463. æFp Files.p
  15464. æT FUNCTION
  15465. æTN $A00E
  15466. æD FUNCTION PBUnmountVol(paramBlock: ParmBlkPtr): OSErr;
  15467. æDT myVariable := PBUnmountVol(paramBlock);
  15468. æRI PBUnmountVol function II-106, IV-134
  15469. æC 
  15470. Trap macro    _UnmountVol
  15471.  
  15472. Parameter block
  15473.   <--    16    ioResult   word
  15474.   -->    18    ioNamePtr  pointer
  15475.   -->    22    ioVRefNum  word
  15476.  
  15477. PBUnmountVol unmounts the volume specified by ioNamePtr or ioVRefNum, by calling
  15478. PBFlushVol to flush the volume, closing all open files on the volume, and releasing
  15479. the memory used for the volume. PBUnmountVol is always executed synchronously.
  15480.  
  15481. Warning:  Don’t unmount the startup volume.
  15482.  
  15483. Note:  Unmounting a volume does not close working directories; to release
  15484.        the memory allocated to a working directory, call PBCloseWD.
  15485.  
  15486. Result codes    noErr     No error
  15487.                 bdNamErr  Bad volume name
  15488.                 extFSErr  External file system
  15489.                 ioErr     I/O error
  15490.                 nsDrvErr  No such drive
  15491.                 nsvErr    No such volume
  15492.                 paramErr  No default volume
  15493.  
  15494. æKY PBWrite
  15495. æFp Files.p
  15496. æT FUNCTION
  15497. æTN $A003
  15498. æD FUNCTION PBWrite(paramBlock: ParmBlkPtr;async: BOOLEAN): OSErr;
  15499. æDT myVariable := PBWrite(paramBlock,async);
  15500. æRT 187
  15501. æRI PBWrite function IV-140  Device Manager II-185  File Manager II-110
  15502. æC 
  15503.  
  15504. •••Refer to Technical Note #187:•••
  15505.  
  15506. Trap macro    _Write
  15507.  
  15508. Parameter block
  15509.   -->    12    ioCompletion  pointer
  15510.   <--    16    ioResult      word
  15511.   -->    24    ioRefNum      word
  15512.   -->    32    ioBuffer      pointer
  15513.   -->    36    ioReqCount    long word
  15514.   <--    40    ioActCount    long word
  15515.   -->    44    ioPosMode     word
  15516.   <->    46    ioPosOffset   long word
  15517.  
  15518. PBWrite takes ioReqCount bytes from the buffer pointed to by ioBuffer and attempts to
  15519. write them to the open file whose access path is specified by ioRefNum. The position
  15520. of the mark is specified by ioPosMode and ioPosOffset. After the write is completed,
  15521. the mark is returned in ioPosOffset and the number of bytes actually written is
  15522. returned in ioActCount.
  15523.  
  15524. Result codes    noErr      No error
  15525.                 dskFulErr  Disk full
  15526.                 fLckdErr   File locked
  15527.                 fnOpnErr   File not open
  15528.                 ioErr      I/O error
  15529.                 paramErr   Negative ioReqCount
  15530.                 posErr     Attempt to position before start of file
  15531.                 rfNumErr   Bad reference number
  15532.                 vLckdErr   Software volume lock
  15533.                 wPrErr     Hardware volume lock
  15534.                 wrPermErr  Read/write permission doesn’t allow writing
  15535.  
  15536. æKY rdVerify
  15537. æFp Files.p
  15538. æC 
  15539. To have the File Manager verify that all data written to a volume exactly matches the
  15540. data in memory, make a Read call right after the Write call. The parameters for a
  15541. read-verify operation are the same as for a standard Read call, except that the
  15542. following constant must be added to the positioning mode:
  15543.  
  15544. CONST  rdVerify = 64;    {read-verify mode}
  15545.  
  15546. The result code ioErr is returned if any of the data doesn’t match.
  15547.  
  15548. æKY Rename
  15549. æFp Files.p
  15550. æT FUNCTION
  15551. æTN $A00B
  15552. æD FUNCTION Rename(oldName: Str255;vRefNum: INTEGER;newName: Str255): OSErr;
  15553. æDT myVariable := Rename(oldName,vRefNum,newName);
  15554. æRI Rename function high-level II-96, IV-114  low-level II-118, IV-153
  15555. æC  
  15556. [Not in ROM]
  15557.  
  15558. Given a file name in oldName, Rename changes the name of the file to newName. Access
  15559. paths currently in use aren’t affected. Given a volume name in oldName or a volume
  15560. reference number in vRefNum, Rename changes the name of the specified volume to
  15561. newName.
  15562.  
  15563. Warning:  If you’re renaming a volume, be sure that both names end with a colon.
  15564.  
  15565. Result codes    noErr        No error
  15566.                 bdNamErr     Bad file name
  15567.                 dirFulErr    Directory full
  15568.                 dupFNErr     Duplicate file name
  15569.                 extFSErr     External file system
  15570.                 fLckdErr     File locked
  15571.                 fnfErr       File not found
  15572.                 fsRnErr      Problem during rename
  15573.                 ioErr        I/O error
  15574.                 nsvErr       No such volume
  15575.                 paramErr     No default volume
  15576.                 vLckdErr     Software volume lock
  15577.                 wPrErr       Hardware volume lock
  15578.  
  15579. æKY RstFLock
  15580. æFp Files.p
  15581. æT FUNCTION
  15582. æD FUNCTION RstFLock(fileName: Str255;vRefNum: INTEGER): OSErr;
  15583. æDT myVariable := RstFLock(fileName,vRefNum);
  15584. æRI RstFLock function II-96, IV-114
  15585. æC 
  15586. [Not in ROM]
  15587.  
  15588. RstFLock unlocks the file having the name fileName on the specified volume. Access
  15589. paths currently in use aren’t affected.
  15590.  
  15591. Result codes    noErr       No error
  15592.                 extFSErr    External file system
  15593.                 fnfErr      File not found
  15594.                 ioErr       I/O error
  15595.                 nsvErr      No such volume
  15596.                 vLckdErr    Software volume lock
  15597.                 wPrErr      Hardware volume lock
  15598.  
  15599. æKY SetEOF
  15600. æFp Files.p
  15601. æT FUNCTION
  15602. æTN $A012
  15603. æD FUNCTION SetEOF(refNum: INTEGER;logEOF: LONGINT): OSErr;
  15604. æDT myVariable := SetEOF(refNum,logEOF);
  15605. æRI SetEOF function  P-132, 180 high-level II-93, IV-111  low-level II-112, IV-142
  15606. æC  
  15607. [Not in ROM]
  15608.  
  15609. SetEOF sets the logical end-of-file of the open file whose access path is specified
  15610. by refNum to the position specified by logEOF. If you attempt to set the logical
  15611. end-of-file beyond the physical end-of-file, the physical end-of-file is set to one
  15612. byte beyond the end of the next free allocation block; if there isn’t enough space on
  15613. the volume, no change is made, and SetEOF returns dskFulErr as its function result.
  15614. If logEOF is 0, all space occupied by the file on the volume is released.
  15615.  
  15616. Result codes    noErr        No error
  15617.                 dskFulErr    Disk full
  15618.                 extFSErr     External file system
  15619.                 fLckdErr     File locked
  15620.                 fnOpnErr     File not open
  15621.                 ioErr        I/O error
  15622.                 rfNumErr     Bad reference number
  15623.                 vLckdErr     Software volume lock
  15624.                 wPrErr       Hardware volume lock
  15625.                 wrPermErr    Read/write permission doesn’t allow writing
  15626.  
  15627. æKY SetFInfo
  15628. æFp Files.p
  15629. æT FUNCTION
  15630. æD FUNCTION SetFInfo(fileName: Str255;vRefNum: INTEGER;fndrInfo: FInfo): OSErr;
  15631. æDT myVariable := SetFInfo(fileName,vRefNum,fndrInfo);
  15632. æRI SetFInfo function II-95, IV-114
  15633. æC  
  15634. [Not in ROM]
  15635.  
  15636. For the file having the name fileName on the specified volume, SetFInfo sets information
  15637. used by the Finder to fndrInfo (see the section “Information Used by the Finder”).
  15638.  
  15639. Result codes    noErr        No error
  15640.                 extFSErr     External file system
  15641.                 fLckdErr     File locked
  15642.                 fnfErr       File not found
  15643.                 ioErr        I/O error
  15644.                 nsvErr       No such volume
  15645.                 vLckdErr     Software volume lock
  15646.                 wPrErr       Hardware volume lock
  15647.  
  15648. æKY SetFLock
  15649. æFp Files.p
  15650. æT FUNCTION
  15651. æD FUNCTION SetFLock(fileName: Str255;vRefNum: INTEGER): OSErr;
  15652. æDT myVariable := SetFLock(fileName,vRefNum);
  15653. æRI SetFLock function II-95, IV-114
  15654. æC  
  15655. [Not in ROM]
  15656.  
  15657. SetFLock locks the file having the name fileName on the specified volume. Access
  15658. paths currently in use aren’t affected.
  15659.  
  15660. Result codes    noErr       No error
  15661.                 extFSErr    External file system
  15662.                 fnfErr      File not found
  15663.                 ioErr       I/O error
  15664.                 nsvErr      No such volume
  15665.                 vLckdErr    Software volume lock
  15666.                 wPrErr      Hardware volume lock
  15667.  
  15668. æKY SetFPos
  15669. æFp Files.p
  15670. æT FUNCTION
  15671. æTN $A044
  15672. æD FUNCTION SetFPos(refNum: INTEGER;posMode: INTEGER;posOff: LONGINT): OSErr;
  15673. æDT myVariable := SetFPos(refNum,posMode,posOff);
  15674. æRI SetFPos function P-131, 132, 180  high-level II-93, IV-110 low-level II-111, IV-141
  15675. æC  
  15676. [Not in ROM]
  15677.  
  15678. SetFPos sets the mark of the open file whose access path is specified by refNum to
  15679. the position specified by posMode and posOff (except when posMode is equal to fsAtMark,
  15680. in which case posOff is ignored). PosMode indicates how to position the mark; it must
  15681. contain one of the following values:
  15682.  
  15683. CONST  fsAtMark     = 0;    {at current mark}
  15684.        fsFromStart  = 1;    {set mark relative to beginning of file}
  15685.        fsFromLEOF   = 2;    {set mark relative to logical end-of-file}
  15686.        fsFromMark   = 3;    {set mark relative to current mark}
  15687.  
  15688. If you specify fsAtMark, posOffset is ignored and the mark is left wherever
  15689. it’s currently positioned. If you choose to set the mark (relative to either the
  15690. beginning of the file, the logical end-of-file, or the current mark), posOffset
  15691. specifies the byte offset from the chosen point (either positive or negative) where
  15692. the mark should be set. If you try to set the mark past the logical end-of-file,
  15693. SetFPos moves the mark to the end-of-file and returns eofErr as its function result.
  15694.  
  15695. Result codes    noErr        No error
  15696.                 eofErr       End-of-file
  15697.                 extFSErr     External file system
  15698.                 fnOpnErr     File not open
  15699.                 ioErr        I/O error
  15700.                 posErr       Attempt to position before start of file
  15701.                 rfNumErr     Bad reference number
  15702.  
  15703. æKY SetVol
  15704. æFp Files.p
  15705. æT FUNCTION
  15706. æTN $A015
  15707. æD FUNCTION SetVol(volName: StringPtr;vRefNum: INTEGER): OSErr;
  15708. æDT myVariable := SetVol(volName,vRefNum);
  15709. æRI SetVol function  high-level II-89, IV-107  low-level II-105, IV-132
  15710. æC  
  15711. [Not in ROM]
  15712.  
  15713. SetVol sets the default volume to the mounted volume specified by volName or vRefNum.
  15714.  
  15715. Result codes    noErr       No error
  15716.                 bdNamErr    Bad volume name
  15717.                 nsvErr      No such volume
  15718.                 paramErr    No default volume
  15719.  
  15720. æKY UnmountVol
  15721. æFp Files.p
  15722. æT FUNCTION
  15723. æTN $A00E
  15724. æD FUNCTION UnmountVol(volName: StringPtr;vRefNum: INTEGER): OSErr;
  15725. æDT myVariable := UnmountVol(volName,vRefNum);
  15726. æRT 180
  15727. æRI UnmountVol function  high-level II-90, IV-108  low-level II-106, IV-134
  15728. æC  
  15729. [Not in ROM]
  15730.  
  15731. UnmountVol unmounts the volume specified by volName or vRefNum, by calling FlushVol
  15732. to flush the volume buffer, closing all open files on the volume, and releasing the
  15733. memory used for the volume.
  15734.  
  15735. Warning:  Don’t unmount the startup volume.
  15736.  
  15737. Result codes    noErr        No error
  15738.                 bdNamErr     Bad volume name
  15739.                 extFSErr     External file system
  15740.                 ioErr        I/O error
  15741.                 nsDrvErr     No such drive
  15742.                 nsvErr       No such volume
  15743.                 paramErr     No default volume
  15744.  
  15745. æKY VCB
  15746. æFp Files.p
  15747. æT RECORD
  15748. æC VCB = RECORD
  15749.    qLink: QElemPtr;
  15750.    qType: INTEGER;
  15751.    vcbFlags: INTEGER;
  15752.    vcbSigWord: INTEGER;
  15753.    vcbCrDate: LONGINT;
  15754.    vcbLsMod: LONGINT;
  15755.    vcbAtrb: INTEGER;
  15756.    vcbNmFls: INTEGER;
  15757.    vcbVBMSt: INTEGER;
  15758.    vcbAllocPtr: INTEGER;
  15759.    vcbNmAlBlks: INTEGER;
  15760.    vcbAlBlkSiz: LONGINT;
  15761.    vcbClpSiz: LONGINT;
  15762.    vcbAlBlSt: INTEGER;
  15763.    vcbNxtCNID: LONGINT;
  15764.    vcbFreeBks: INTEGER;
  15765.    vcbVN: Str27;
  15766.    vcbDrvNum: INTEGER;
  15767.    vcbDRefNum: INTEGER;
  15768.    vcbFSID: INTEGER;
  15769.    vcbVRefNum: INTEGER;
  15770.    vcbMAdr: Ptr;
  15771.    vcbBufAdr: Ptr;
  15772.    vcbMLen: INTEGER;
  15773.    vcbDirIndex: INTEGER;
  15774.    vcbDirBlk: INTEGER;
  15775.    vcbVolBkUp: LONGINT;
  15776.    vcbVSeqNum: INTEGER;
  15777.    vcbWrCnt: LONGINT;
  15778.    vcbXTClpSiz: LONGINT;
  15779.    vcbCTClpSiz: LONGINT;
  15780.    vcbNmRtDirs: INTEGER;
  15781.    vcbFilCnt: LONGINT;
  15782.    vcbDirCnt: LONGINT;
  15783.    vcbFndrInfo: ARRAY [1..8] OF LONGINT;
  15784.    vcbVCSize: INTEGER;
  15785.    vcbVBMCSiz: INTEGER;
  15786.    vcbCtlCSiz: INTEGER;
  15787.    vcbXTAlBlks: INTEGER;
  15788.    vcbCTAlBlks: INTEGER;
  15789.    vcbXTRef: INTEGER;
  15790.    vcbCTRef: INTEGER;
  15791.    vcbCtlBuf: Ptr;
  15792.    vcbDirIDM: LONGINT;
  15793.    vcbOffsM: INTEGER;
  15794.    END;
  15795.  
  15796.  
  15797. »Volume Control Blocks
  15798.  
  15799. •••Refer to Technical Note #106:•••
  15800.  
  15801. Each time a volume is mounted, its volume information is read from it and is used to
  15802. build a new volume control block in the volume-control-block queue
  15803. (unless an ejected or off-line volume is being remounted). A copy of the volume block
  15804. map is also read from the volume and placed in the system heap, and a volume buffer
  15805. is created in the system heap.
  15806.  
  15807. The volume-control-block queue is a standard Operating System queue that’s maintained
  15808. in the system heap. It contains a volume control block for each mounted volume. A
  15809. volume control block is a 178-byte nonrelocatable block that contains volume-specific
  15810. information. It has the following structure:
  15811.  
  15812. TYPE VCB = RECORD
  15813.              qLink:        QElemPtr;   {next queue entry}
  15814.              qType:        INTEGER;    {queue type}
  15815.              vcbFlags:     INTEGER;    {bit 15=1 if dirty}
  15816.              vcbSigWord:   INTEGER;    {$4244 for hierarchical, $D2D7 for flat}
  15817.              vcbCrDate:    LONGINT;    {date and time of initialization}
  15818.              vcbLsMod:     LONGINT;    {date and time of last modification}
  15819.              vcbAtrb:      INTEGER;    {volume attributes}
  15820.              vcbNmFls:     INTEGER;    {number of files in directory}
  15821.              vcbVBMSt:     INTEGER;    {first block of volume bit map}
  15822.              vcbAllocPtr:  INTEGER;    {used internally}
  15823.              vcbNmAlBlks:  INTEGER;    {number of allocation blocks}
  15824.              vcbAlBlkSiz:  LONGINT;    {allocation block size}
  15825.              vcbClpSiz:    LONGINT;    {default clump size}
  15826.              vcbAlBlSt:    INTEGER;    {first block in block map}
  15827.              vcbNxtCNID:   LONGINT;    {next unused directory ID or file number}
  15828.              vcbFreeBks:   INTEGER;    {number of unused allocation blocks}
  15829.              vcbVN:        STRING[27]; {volume name}
  15830.              vcbDrvNum:    INTEGER;    {drive number}
  15831.              vcbDRefNum:   INTEGER;    {driver reference number}
  15832.              vcbFSID:      INTEGER;    {file-system identifier}
  15833.              vcbVRefNum:   INTEGER;    {volume reference number}
  15834.              vcbMAdr:      Ptr;        {pointer to block map}
  15835.              vcbBufAdr:    Ptr;        {pointer to volume buffer}
  15836.              vcbMLen:      INTEGER;    {number of bytes in block map}
  15837.              vcbDirIndex:  INTEGER;    {used internally}
  15838.              vcbDirBlk:    INTEGER;    {used internally}
  15839.              vcbVolBkUp:   LONGINT;    {date and time of last backup}
  15840.              vcbVSeqNum:   INTEGER;    {used internally}
  15841.              vcbWrCnt:     LONGINT;    {volume write count}
  15842.              vcbXTClpSiz:  LONGINT;    {clump size of extents tree file}
  15843.              vcbCTClpSiz:  LONGINT;    {clump size of catalog tree file}
  15844.              vcbNmRtDirs:  INTEGER;    {number of directories in root}
  15845.              vcbFilCnt:    LONGINT;    {number of files on volume}
  15846.              vcbDirCnt:    LONGINT;    {number of directories on volume}
  15847.              vcbFndrInfo:  ARRAY[1..8] OF LONGINT;  {information used by }
  15848.                                                     { the Finder}
  15849.              vcbVCSize:    INTEGER;    {used internally}
  15850.              vcbVBMCSiz:   INTEGER;    {used internally}
  15851.              vcbCtlCSiz:   INTEGER;    {used internally}
  15852.              vcbXTAlBks:   INTEGER;    {size in blocks of extents tree file}
  15853.              vcbCTAlBks:   INTEGER;    {size in blocks of catalog tree file}
  15854.              vcbXTRef:     INTEGER;    {path reference number for extents }
  15855.                                        { tree file}
  15856.              vcbCTRef:     INTEGER;    {path reference number for catalog }
  15857.                                        { tree file}
  15858.              vcbCtlBuf:    Ptr;        {pointer to extents and catalog }
  15859.                                        { tree caches}
  15860.              vcbDirIDM:    LONGINT;    {directory last searched}
  15861.              vcbOffsM:     INTEGER     {offspring index at last search}
  15862.            END;
  15863.  
  15864. 64K ROM note:  A volume control block created for a flat volume is a subset
  15865.                of the above structure. It’s actually smaller and contains
  15866.                only the fields up to and including vcbDirBlk. In addition,
  15867.                the names of several fields have been changed to reflect the
  15868.                fact that they contain different information on hierarchical
  15869.                volumes:  vcbLsBkUp, vcbDirSt, vcbBlLn, vcbNmBlks, and
  15870.                vcbNxtFNum have been changed to vcbLsMod, vcbVBMSt,
  15871.                vcbAllocPtr, vcbNmAlBlks, and vcbNxtCNID respectively.
  15872.  
  15873. QLink points to the next entry in the queue, and qType indicates the queue type,
  15874. which must always be ORD(fsQType). Bit 15 of vcbFlags is set if the volume information
  15875. has been changed by a routine call since the volume was last affected by a FlushVol
  15876. call.
  15877.  
  15878. VCBLsMod contains the date and time that the volume was last modified (this is not
  15879. necessarily when it was flushed).
  15880.  
  15881. 64K ROM note:  VCBLsMod replaces the field vcbLsBkUp from flat directory
  15882.                volumes. The name vcbLsBkUp was actually a misnomer; this
  15883.                field has always contained the date and time of the last
  15884.                modification, not the last backup. Another field, vcbVolBkUp,
  15885.                contains the date and time of the last backup.
  15886.  
  15887. VCBAtrb contains the volume attributes, as follows:
  15888.  
  15889.   Bit    Meaning
  15890.   0–4    Set if inconsistencies were found between the volume
  15891.          information and the file directory when the volume was mounted
  15892.   6      Set if volume is busy (one or more files are open)
  15893.   7      Set if volume is locked by hardware
  15894.   15     Set if volume is locked by software
  15895.  
  15896. VCBVBMSt contains the number of the first block in the volume bit map; on flat volumes,
  15897. it contains the first block of the file directory. VCBNmAlBlks contains the number of
  15898. allocation blocks on the volume, and vcbFreeBks specifies how many of those blocks
  15899. are unused. VCBAlBlSt is used only with flat volumes; it contains the number of the
  15900. first block in the block map.
  15901.  
  15902. VCBDrvNum contains the drive number of the drive on which the volume is mounted;
  15903. vcbDRefNum contains the driver reference number of the driver used to access the
  15904. volume. When a mounted volume is placed off-line, vcbDrvNum is cleared. When a volume
  15905. is ejected, vcbDrvNum is cleared and vcbDRefNum is set to the negative of vcbDrvNum
  15906. (becoming a positive number). VCBFSID identifies the file system handling the volume;
  15907. it’s 0 for volumes handled by the File Manager, and nonzero for volumes handled by
  15908. other file systems.
  15909.  
  15910. When a volume is placed off-line, its buffer and bit map (or block map, in the case
  15911. of flat directory volumes) are released. When a volume is unmounted, its volume
  15912. control block is removed from the volume-control-block queue.
  15913.  
  15914. You can get a pointer to the header of the volume-control-block queue by calling the
  15915. File Manager function GetVCBQHdr.
  15916.  
  15917. æKY FixMath.p
  15918. æKL Fix2Frac
  15919. Fix2Long
  15920. Fix2X
  15921. FixATan2
  15922. FixDiv
  15923. Frac2Fix
  15924. Frac2X
  15925. FracCos
  15926. FracDiv
  15927. FracMul
  15928. FracSin
  15929. FracSqrt
  15930. Long2Fix
  15931. X2Fix
  15932. X2Frac
  15933.  
  15934.  
  15935. æKY Fix2Frac
  15936. æFp FixMath.p
  15937. æT FUNCTION
  15938. æTN $A841
  15939. æD FUNCTION Fix2Frac(x: Fixed): Fract;
  15940. æDT myVariable := Fix2Frac(x);
  15941. æRI Fix2Frac function  IV-65
  15942. æC 
  15943. Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between fixed-point types.
  15944.  
  15945. Examples
  15946.  
  15947. Examples of the use of these fixed-point functions are provided below; all numbers
  15948. are decimal unless otherwise noted.
  15949.  
  15950. Function                                 Result      Comment
  15951. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  15952. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  15953. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  15954. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  15955. FracSin   (X2Fix(3.1416015625))          $00000000    0
  15956. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  15957. Fix2Long  (X2Fix(1.75))                  $00000002    2
  15958. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  15959. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  15960. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  15961. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  15962. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  15963. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  15964. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  15965. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  15966. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  15967. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  15968. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  15969. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  15970.  
  15971. æKY Fix2Long
  15972. æFp FixMath.p
  15973. æT FUNCTION
  15974. æTN $A840
  15975. æD FUNCTION Fix2Long(x: Fixed): LONGINT;
  15976. æDT myVariable := Fix2Long(x);
  15977. æRI Fix2Long function IV-65
  15978. æC 
  15979. Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between fixed-point types.
  15980.  
  15981. Examples
  15982.  
  15983. Examples of the use of these fixed-point functions are provided below; all numbers
  15984. are decimal unless otherwise noted.
  15985.  
  15986. Function                                 Result      Comment
  15987. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  15988. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  15989. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  15990. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  15991. FracSin   (X2Fix(3.1416015625))          $00000000    0
  15992. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  15993. Fix2Long  (X2Fix(1.75))                  $00000002    2
  15994. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  15995. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  15996. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  15997. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  15998. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  15999. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  16000. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  16001. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  16002. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  16003. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  16004. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  16005. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  16006.  
  16007. æKY Fix2X
  16008. æFp FixMath.p
  16009. æT FUNCTION
  16010. æTN $A843
  16011. æD FUNCTION Fix2X(x: Fixed): Extended;
  16012. æDT myVariable := Fix2X(x);
  16013. æRI Fix2X function  IV-65
  16014. æC 
  16015. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract and the Extended
  16016. floating-point type. These functions do not set floating-point exception flags.
  16017.  
  16018. Examples
  16019.  
  16020. Examples of the use of these fixed-point functions are provided below; all numbers
  16021. are decimal unless otherwise noted.
  16022.  
  16023. Function                                 Result      Comment
  16024. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  16025. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  16026. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  16027. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  16028. FracSin   (X2Fix(3.1416015625))          $00000000    0
  16029. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  16030. Fix2Long  (X2Fix(1.75))                  $00000002    2
  16031. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  16032. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  16033. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  16034. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  16035. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  16036. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  16037. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  16038. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  16039. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  16040. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  16041. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  16042. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  16043.  
  16044. æKY FixATan2
  16045. æFp FixMath.p
  16046. æT FUNCTION
  16047. æTN $A818
  16048. æD FUNCTION FixATan2(x: LONGINT;y: LONGINT): Fixed;
  16049. æDT myVariable := FixATan2(x,y);
  16050. æRI FixATan2 function  IV-65
  16051. æC 
  16052. FixATan2 returns the arctangent of y / x in radians. Note that FixATan2 effects
  16053. “arctan(type / type) --> Fixed”:
  16054.  
  16055.   arctan(LONGINT / LONGINT)  -->    Fixed
  16056.   arctan(Fixed / Fixed)      -->    Fixed
  16057.   arctan(Fract / Fract)      -->    Fixed
  16058.  
  16059. æKY FixDiv
  16060. æFp FixMath.p
  16061. æT FUNCTION
  16062. æTN $A84D
  16063. æD FUNCTION FixDiv(x: Fixed;y: Fixed): Fixed;
  16064. æDT myVariable := FixDiv(x,y);
  16065. æRI FixDiv function  IV-64
  16066. æC 
  16067. FixDiv returns x / y. Note that FixDiv effects “type / type --> Fixed” and
  16068. “type / Fixed --> type”:
  16069.  
  16070.   Fixed    /    Fixed    -->    Fixed
  16071.   LONGINT  /    LONGINT  -->    Fixed
  16072.   Fract    /    Fract    -->    Fixed
  16073.   LONGINT  /    Fixed    -->    LONGINT
  16074.   Fract    /    Fixed    -->    Fract
  16075.  
  16076. æKY Frac2Fix
  16077. æFp FixMath.p
  16078. æT FUNCTION
  16079. æTN $A842
  16080. æD FUNCTION Frac2Fix(x: Fract): Fixed;
  16081. æDT myVariable := Frac2Fix(x);
  16082. æRI Frac2Fix function  IV-65
  16083. æC 
  16084. Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between fixed-point types.
  16085.  
  16086. Examples
  16087.  
  16088. Examples of the use of these fixed-point functions are provided below; all numbers
  16089. are decimal unless otherwise noted.
  16090.  
  16091. Function                                 Result      Comment
  16092. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  16093. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  16094. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  16095. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  16096. FracSin   (X2Fix(3.1416015625))          $00000000    0
  16097. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  16098. Fix2Long  (X2Fix(1.75))                  $00000002    2
  16099. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  16100. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  16101. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  16102. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  16103. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  16104. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  16105. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  16106. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  16107. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  16108. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  16109. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  16110. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  16111.  
  16112. æKY Frac2X
  16113. æFp FixMath.p
  16114. æT FUNCTION
  16115. æTN $A845
  16116. æD FUNCTION Frac2X(x: Fract): Extended;
  16117. æDT myVariable := Frac2X(x);
  16118. æRI Frac2X function  IV-65
  16119. æC 
  16120. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract and the Extended
  16121. floating-point type. These functions do not set floating-point exception flags.
  16122.  
  16123. Examples
  16124.  
  16125. Examples of the use of these fixed-point functions are provided below; all numbers
  16126. are decimal unless otherwise noted.
  16127.  
  16128. Function                                 Result      Comment
  16129. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  16130. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  16131. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  16132. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  16133. FracSin   (X2Fix(3.1416015625))          $00000000    0
  16134. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  16135. Fix2Long  (X2Fix(1.75))                  $00000002    2
  16136. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  16137. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  16138. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  16139. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  16140. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  16141. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  16142. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  16143. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  16144. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  16145. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  16146. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  16147. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  16148.  
  16149. æKY FracCos
  16150. æFp FixMath.p
  16151. æT FUNCTION
  16152. æTN $A847
  16153. æD FUNCTION FracCos(x: Fixed): Fract;
  16154. æDT myVariable := FracCos(x);
  16155. æRI FracCos function  IV-64
  16156. æC 
  16157. FracCos and FracSin return the cosine and sine of their radian arguments, respectively.
  16158. The hexadecimal value 0.C910 (which is FixATan2(1,1)) is the approximation to π/4
  16159. used for argument reduction. Thus, FracCos and FracSin are nearly periodic, but with
  16160. period 2*P instead of 2*π, where P=3.1416015625 and π, of course, is 3.14159265....
  16161.  
  16162. æKY FracDiv
  16163. æFp FixMath.p
  16164. æT FUNCTION
  16165. æTN $A84B
  16166. æD FUNCTION FracDiv(x: Fract;y: Fract): Fract;
  16167. æDT myVariable := FracDiv(x,y);
  16168. æRI FracDiv function  IV-64
  16169. æC 
  16170. FracDiv returns x / y. Note that FracDiv effects “type / type --> Fract” and
  16171. “type / Fract --> type”:
  16172.  
  16173.   Fract    /    Fract    -->    Fract
  16174.   LONGINT  /    LONGINT  -->    Fract
  16175.   Fixed    /    Fixed    -->    Fract
  16176.   LONGINT  /    Fract    -->    LONGINT
  16177.   Fixed    /    Fract    -->    Fixed
  16178.  
  16179. æKY FracMul
  16180. æFp FixMath.p
  16181. æT FUNCTION
  16182. æTN $A84A
  16183. æD FUNCTION FracMul(x: Fract;y: Fract): Fract;
  16184. æDT myVariable := FracMul(x,y);
  16185. æRI FracMul function  IV-64
  16186. æC 
  16187. FracMul returns x * y. Note that FracMul effects “type * Fract --> type”:
  16188.  
  16189.   Fract    *    Fract    -->    Fract
  16190.   LONGINT  *    Fract    -->    LONGINT
  16191.   Fract    *    LONGINT  -->    LONGINT
  16192.   Fixed    *    Fract    -->    Fixed
  16193.   Fract    *    Fixed    -->    Fixed
  16194.  
  16195. æKY FracSin
  16196. æFp FixMath.p
  16197. æT FUNCTION
  16198. æTN $A848
  16199. æD FUNCTION FracSin(x: Fixed): Fract;
  16200. æDT myVariable := FracSin(x);
  16201. æRI FracSin function  IV-64
  16202. æC 
  16203. FracCos and FracSin return the cosine and sine of their radian arguments, respectively.
  16204. The hexadecimal value 0.C910 (which is FixATan2(1,1)) is the approximation to π/4
  16205. used for argument reduction. Thus, FracCos and FracSin are nearly periodic, but with
  16206. period 2*P instead of 2*π, where P=3.1416015625 and π, of course, is 3.14159265....
  16207.  
  16208. æKY FracSqrt
  16209. æFp FixMath.p
  16210. æT FUNCTION
  16211. æTN $A849
  16212. æD FUNCTION FracSqrt(x: Fract): Fract;
  16213. æDT myVariable := FracSqrt(x);
  16214. æRI FracSqrt function  IV-64
  16215. æC  
  16216. FracSqrt returns the square root of x, with x interpreted as unsigned in the range 0
  16217. through 4–(2–30), inclusive:  That is, bit 15 in Figure 1 has weight 2 rather than
  16218. –2. The result, too, is unsigned in the range 0 through 2, inclusive.
  16219.  
  16220. æKY Long2Fix
  16221. æFp FixMath.p
  16222. æT FUNCTION
  16223. æTN $A83F
  16224. æD FUNCTION Long2Fix(x: LONGINT): Fixed;
  16225. æDT myVariable := Long2Fix(x);
  16226. æRI Long2Fix function  IV-65
  16227. æC 
  16228. Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between fixed-point types.
  16229.  
  16230. Examples
  16231.  
  16232. Examples of the use of these fixed-point functions are provided below; all numbers
  16233. are decimal unless otherwise noted.
  16234.  
  16235. Function                                 Result      Comment
  16236. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  16237. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  16238. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  16239. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  16240. FracSin   (X2Fix(3.1416015625))          $00000000    0
  16241. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  16242. Fix2Long  (X2Fix(1.75))                  $00000002    2
  16243. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  16244. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  16245. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  16246. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  16247. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  16248. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  16249. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  16250. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  16251. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  16252. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  16253. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  16254. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  16255.  
  16256. æKY X2Fix
  16257. æFp FixMath.p
  16258. æT FUNCTION
  16259. æTN $A844
  16260. æD FUNCTION X2Fix(x: Extended): Fixed;
  16261. æDT myVariable := X2Fix(x);
  16262. æRI X2Fix function  IV-65
  16263. æC 
  16264. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract and the Extended
  16265. floating-point type. These functions do not set floating-point exception flags.
  16266.  
  16267. Examples
  16268.  
  16269. Examples of the use of these fixed-point functions are provided below; all numbers
  16270. are decimal unless otherwise noted.
  16271.  
  16272. Function                                 Result      Comment
  16273. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  16274. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  16275. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  16276. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  16277. FracSin   (X2Fix(3.1416015625))          $00000000    0
  16278. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  16279. Fix2Long  (X2Fix(1.75))                  $00000002    2
  16280. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  16281. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  16282. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  16283. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  16284. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  16285. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  16286. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  16287. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  16288. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  16289. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  16290. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  16291. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  16292.  
  16293. æKY X2Frac
  16294. æFp FixMath.p
  16295. æT FUNCTION
  16296. æTN $A846
  16297. æD FUNCTION X2Frac(x: Extended): Fract;
  16298. æDT myVariable := X2Frac(x);
  16299. æRI X2Frac function  IV-65
  16300. æC 
  16301. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract and the Extended
  16302. floating-point type. These functions do not set floating-point exception flags.
  16303.  
  16304. Examples
  16305.  
  16306. Examples of the use of these fixed-point functions are provided below; all numbers
  16307. are decimal unless otherwise noted.
  16308.  
  16309. Function                                 Result      Comment
  16310. FixDiv    (X2Fix(1.95), X2Fix(1.30))     $00018000    1.5 = 01.10 bin
  16311. FracDiv   (X2Frac(1.95), X2Frac(1.30))   $60000000    1.5 = 01.10 bin
  16312. FracMul   (X2Frac(1.50), X2Frac(1.30))   $7CCCCCCD    1.95 rounded
  16313. FracSqrt  (X2Frac(1.96))                 $5999999A    1.4 rounded
  16314. FracSin   (X2Fix(3.1416015625))          $00000000    0
  16315. FracCos   (X2Fix(3.1416015625))          $C0000000   -1
  16316. Fix2Long  (X2Fix(1.75))                  $00000002    2
  16317. Fix2Frac  (X2Fix(1.75))                  $70000000    1.75 = 01.11 bin
  16318. Frac2Fix  (X2Frac(1.75))                 $0001C000    1.75 = 01.11 bin
  16319. FixATan2  (X2Fix(1.00), X2Fix(1.00))     $0000C910    0.C910 hex = X2Fix (π/4)
  16320. FixDiv    (X2Fix(-1.95), X2Fix(1.30))    $FFFE8000   -1.5
  16321. FracDiv   (X2Frac(-1.95), X2Frac(1.30))  $A0000000   -1.5
  16322. FracMul   (X2Frac(-1.50), X2Frac(1.30))  $83333333   -1.95 rounded
  16323. FracSin   (X2Fix(-3.1416015625))         $00000000    0
  16324. FracCos   (X2Fix(-3.1416015625))         $C0000000   -1
  16325. Fix2Long  (X2Fix(-1.75))                 $FFFFFFFE   -2
  16326. Fix2Frac  (X2Fix(-1.75))                 $90000000   -1.75
  16327. Frac2Fix  (X2Frac(-1.75))                $FFFE4000   -1.75
  16328. FixATan2  (X2Fix(-1.00), X2Fix(-1.00))   $FFFDA4D0   -3*X2Fix(π/4)=3*0.C910 hex
  16329.  
  16330. æKY Fonts.p
  16331. æKL FMSwapFont
  16332. FontMetrics
  16333. GetFNum
  16334. GetFontName
  16335. InitFonts
  16336. RealFont
  16337. SetFontLock
  16338. SetFractEnable
  16339. SetFScaleDisable
  16340.  
  16341. appleMark
  16342. applFont
  16343. AsscEntry
  16344. athens
  16345. cairo
  16346. checkMark
  16347. commandMark
  16348. courier
  16349. diamondMark
  16350. FamRec
  16351. fixedFont
  16352. FMetricRec
  16353. FMInput
  16354. FMOutPtr
  16355. FMOutput
  16356. FontAssoc
  16357. FontRec
  16358. fontWid
  16359. fxdFntH
  16360. fxdFntHW
  16361. fxdFntW
  16362. geneva
  16363. helvetica
  16364. InitFonts
  16365. InitFonts
  16366. KernEntry
  16367. KernPair
  16368. KernTable
  16369. london
  16370. losAngeles
  16371. mobile
  16372. monaco
  16373. NameTable
  16374. newYork
  16375. propFont
  16376. prpFntH
  16377. prpFntHW
  16378. prpFntW
  16379. sanFran
  16380. StyleTable
  16381. symbol
  16382. systemFont
  16383. taliesin
  16384. times
  16385. toronto
  16386. venice
  16387. WidEntry
  16388. WidthTable
  16389.  
  16390. æKY FMOutput,FMOutPtr
  16391. æFp Fonts.p
  16392. æT TYPE
  16393. æC FMOutPtr = ^FMOutput;
  16394. FMOutput = PACKED RECORD
  16395.    errNum: INTEGER;
  16396.    fontHandle: Handle;
  16397.    bold: Byte;
  16398.    italic: Byte;
  16399.    ulOffset: Byte;
  16400.    ulShadow: Byte;
  16401.    ulThick: Byte;
  16402.    shadow: Byte;
  16403.    extra: SignedByte;
  16404.    ascent: Byte;
  16405.    descent: Byte;
  16406.    widMax: Byte;
  16407.    leading: SignedByte;
  16408.    unused: Byte;
  16409.    numer: Point;
  16410.    denom: Point;
  16411.    END;
  16412.  
  16413. Based on the information in the font characterization table, the Font Manager determines
  16414. the optimum ascent, descent, and leading, so that the highest-quality printing or
  16415. drawing available will be produced. It then stores this information in a font output
  16416. record:
  16417.  
  16418. TYPE FMOutput = PACKED RECORD
  16419.                   errNum:      INTEGER;     {not used}
  16420.                   fontHandle:  Handle;      {handle to font record}
  16421.                   bold:        Byte;        {bold factor}
  16422.                   italic:      Byte;        {italic factor}
  16423.                   ulOffset:    Byte;        {underline offset}
  16424.                   ulShadow:    Byte;        {underline shadow}
  16425.                   ulThick:     Byte;        {underline thickness}
  16426.                   shadow:      Byte;        {shadow factor}
  16427.                   extra:       SignedByte;  {width of style}
  16428.                   ascent:      Byte;        {ascent}
  16429.                   descent:     Byte;        {descent}
  16430.                   widMax:      Byte;        {maximum character width}
  16431.                   leading:     SignedByte;  {leading}
  16432.                   unused:      Byte;        {not used}
  16433.                   numer:       Point;       {numerators of scaling factors}
  16434.                   denom:       Point        {denominators of scaling factors}
  16435.                 END;
  16436.  
  16437. ErrNum is reserved for future use, and is set to 0. FontHandle is a handle to the
  16438. font record of the font, as described in the next section. Bold, italic, ulOffset,
  16439. ulShadow, ulThick, and shadow are all fields that modify the way stylistic variations
  16440. are done; their values are taken from the font characterization table, and are used
  16441. by QuickDraw. (You’ll need to experiment with these values if you want to determine
  16442. exactly how they’re used.) Extra indicates the number of pixels that each character
  16443. has been widened by stylistic variation. For example, using the screen values shown
  16444. in Figure 22, the extra field for bold shadowed characters would be 3. Ascent, descent,
  16445. widMax, and leading are the same as the fields of the FontInfo record returned by the
  16446. QuickDraw procedure GetFontInfo. Numer and denom contain the scaling factors.
  16447.  
  16448. Just before returning this record to QuickDraw, the Font Manager calls the device
  16449. driver’s control routine to allow the driver to make any final modifications to the
  16450. record. Finally, the font information is returned to QuickDraw via a pointer to the
  16451. record, defined as follows:
  16452.  
  16453. TYPE FMOutPtr = ^FMOutput;
  16454.  
  16455. Note:  If you want to make your own calls to the device driver’s Control
  16456.        function, the reference number must be the driver reference number
  16457.        from the font input record’s device field, csCode must be 8, csParam
  16458.        must be a pointer to the font output record, and csParam+4 must be
  16459.        the value of the font input record’s device field.
  16460.  
  16461. æKY AsscEntry
  16462. æFp Fonts.p
  16463. æT RECORD
  16464. æC AsscEntry = RECORD
  16465.    fontSize: INTEGER;
  16466.    fontStyle: INTEGER;
  16467.    fontID: INTEGER;                        {font resource ID}
  16468.    END;
  16469.  
  16470. æKY commandMark,checkMark,diamondMark,appleMark
  16471. æFp Fonts.p
  16472. æC 
  16473. _______________________________________________________________________________
  16474. »CHARACTERS IN A FONT
  16475. _______________________________________________________________________________
  16476.  
  16477. Note:  The information on the Characters In A Font described in the following
  16478.        paragraphs was originally documented in Inside Macintosh, Volume I.
  16479.  
  16480. A font can consist of up to 255 distinct characters; not all characters need to be
  16481. defined in a single font. Figure 20 shows the standard printing characters on the
  16482. Macintosh and their ASCII codes (for example, the ASCII code for “A” is 41 hexadecimal,
  16483. or 65 decimal).
  16484.  
  16485. Note:  Codes $00 through $1F and code $7F are normally nonprinting
  16486.        characters (see the Toolbox Event Manager chapter for details).
  16487.  
  16488. The special characters in the system font with codes $11 through $14 can’t normally
  16489. be typed from the keyboard or keypad. The Font Manager defines constants for these
  16490. characters:
  16491.  
  16492. CONST  commandMark  = $11;    {Command key symbol}
  16493.        checkMark    = $12;    {check mark}
  16494.        diamondMark  = $13;    {diamond symbol}
  16495.        appleMark    = $14;    {apple symbol}
  16496.  
  16497. In addition to its maximum of 255 characters, every font contains a missing symbol
  16498. that’s drawn in case of a request to draw a character that’s missing from the font.
  16499.  
  16500. •••Refer to Figure 20.•••
  16501.  
  16502. Figure 20–Font Characters
  16503.  
  16504. æKY FamRec
  16505. æFp Fonts.p
  16506. æT RECORD
  16507. æC FamRec = RECORD
  16508.    ffFlags: INTEGER;                       {flags for family}
  16509.    ffFamID: INTEGER;                       {family ID number}
  16510.    ffFirstChar: INTEGER;                   {ASCII code of 1st character}
  16511.    ffLastChar: INTEGER;                    {ASCII code of last character}
  16512.    ffAscent: INTEGER;                      {maximum ascent for 1pt font}
  16513.    ffDescent: INTEGER;                     {maximum descent for 1pt font}
  16514.    ffLeading: INTEGER;                     {maximum leading for 1pt font}
  16515.    ffWidMax: INTEGER;                      {maximum widMax for 1pt font}
  16516.    ffWTabOff: LONGINT;                     {offset to width table}
  16517.    ffKernOff: LONGINT;                     {offset to kerning table}
  16518.    ffStylOff: LONGINT;                     {offset to style mapping table}
  16519.    ffProperty: ARRAY [1..9] OF INTEGER;    {style property info}
  16520.    ffIntl: ARRAY [1..2] OF INTEGER;        {for international use}
  16521.    ffVersion: INTEGER;                     {version number}
  16522.    END;
  16523.  
  16524. »Family Records
  16525.  
  16526. Note:  The extensions to the Font Manager described in the following paragraphs
  16527.        were originally documented in Inside Macintosh, Volume IV.  As such,
  16528.        this information refers to the 128K ROMs and System file version 3.2
  16529.        and later.
  16530.  
  16531. Assembly-language note:  The global variable LastFOND is a handle to the last
  16532.                          family record used. You can read the contents of the
  16533.                          family record by using this handle. You should not
  16534.                          alter the contents of this record.
  16535.  
  16536. The data type for a family record is as follows:
  16537.  
  16538. TYPE FamRec = RECORD
  16539.                 ffFlags:      INTEGER;    {flags for family}
  16540.                 ffFamID:      INTEGER;    {family ID number}
  16541.                 ffFirstChar:  INTEGER;    {ASCII code of the first character}
  16542.                 ffLastChar:   INTEGER;    {ASCII code of the last character}
  16543.                 ffAscent:     INTEGER;    {maximum ascent for 1-pt.font}
  16544.                 ffDescent:    INTEGER;    {maximum descent for 1-pt.font}
  16545.                 ffLeading:    INTEGER;    {maximum leading for 1-pt.font}
  16546.                 ffWidMax:     INTEGER;    {maximum width for 1-pt.font}
  16547.                 ffWTabOff:    LONGINT;    {offset to width table}
  16548.                 ffKernOff:    LONGINT;    {offset to kerning table}
  16549.                 ffStylOff:    LONGINT;    {offset to style-mapping table}
  16550.                 ffProperty:   ARRAY[1..9] OF INTEGER; {style property info}
  16551.                 ffIntl:       ARRAY[1..2] OF INTEGER; {reserved}
  16552.                 ffVersion:    INTEGER;    {version number}
  16553.              {  ffAssoc:      FontAssoc;} {font association table}
  16554.              {  ffWidthTab:   WidTable;}  {width table}
  16555.              {  ffStyTab:     StyleTable;}{style-mapping table}
  16556.              {  ffKernTab:    KernTable;} {kerning table}
  16557.               END;
  16558.  
  16559. Note:  The variable-length arrays appear as comments because they’re not
  16560.        valid Pascal syntax; they’re used only as conceptual aids.  This
  16561.        version of the FamRec is accurate for Volume IV; the extensions to
  16562.        the FamRec made in Volume V are not included here.
  16563.  
  16564. The ffFlags field defines general characteristics of the font family, as follows:
  16565.  
  16566.   Bit    Meaning
  16567.   0      Set if there’s an image-height table
  16568.   1      Set if there’s a character-width table
  16569.   2–11   Reserved (should be zero)
  16570.   12     Set to ignore FractEnable when deciding whether to use
  16571.          fixed-point values for stylistic variations (see bit 13),
  16572.          clear to treat FractEnable as usual
  16573.   13     Set to use integer extra width for stylistic variations,
  16574.          clear to compute fixed-point extra width from the family
  16575.          style-mapping table when FractEnable is TRUE
  16576.   14     Set if family fractional-width table is not used, clear
  16577.          if table is used
  16578.   15     Set for fixed-width font, clear for proportional font
  16579.  
  16580. The values in the ffAscent, ffDescent, ffLeading, and ffWidMax describe the maximum
  16581. dimensions of the family as they would be for a hypothetical one-point font to be
  16582. scaled up. They use a special 16-bit fixed-point format with an integer part in the
  16583. high-order 4 bits and a fractional part in the low-order 12 bits. The FontMetrics
  16584. procedure calculates the true values by multiplying this number by the actual point
  16585. size.
  16586.  
  16587. The ffWTabOff, ffKernOff, and ffStylOff fields are offsets from the top of the record
  16588. to the start of the width table, kerning table, and style-mapping table, respectively;
  16589. if any of these fields is zero, the corresponding table does not exist.
  16590.  
  16591. The ffProperty field is the family style-property table, shown in Figure 11.
  16592.  
  16593. •••Refer to Figure 11.•••
  16594.  
  16595. Figure 11–Family Style-Property Table
  16596.  
  16597. Each entry is a 16-bit fixed-point number with a signed integer part in the high-order
  16598. 4 bits and a fractional part in the low-order 12 bits. These numbers are used to
  16599. calculate the amount of extra width for special stylistic variations; each of these
  16600. values is multiplied by the point size of the font actually being used. If the font
  16601. already exists for a given style, the value in its field is ignored.
  16602.  
  16603. The ffAssoc field contains the font association table. This table, shown in Figure
  16604. 12, is used to match a given font size and style combination with the resource ID of
  16605. an actual font.
  16606.  
  16607. •••Refer to Figure 12.•••
  16608.  
  16609. Figure 12–Font Association Table
  16610.  
  16611. Note:  In order to reduce search time, the Font Manager requires that
  16612.        the entries be sorted according to the fontSize field, with the
  16613.        smallest sizes first. If multiple fonts from the same family, the
  16614.        plain (roman) fonts come first. The Font Manager is optimized to
  16615.        look first for 'NFNT' resources, then 'FONT' resources.
  16616.  
  16617. Each entry in the font association table has the format shown in Figure 13.
  16618.  
  16619. •••Refer to Figure 13.•••
  16620.  
  16621. Figure 13–Font Association Table Entry
  16622.  
  16623. The font association table is followed by the family character-width table. As shown
  16624. in Figure 14, this table is actually a number of width tables (since a font family
  16625. may include numerous styles).
  16626.  
  16627. •••Refer to Figure 14.•••
  16628.  
  16629. Figure 14–Family Character-Width Table
  16630.  
  16631. Each character-width table is preceded by a style code; the low-order byte of this
  16632. word specifies stylistic variations (see Figure 15). The widths in each table are for
  16633. a hypothetical one-point font; the actual values for the characters are calculated by
  16634. multiplying these widths by the font size. The widths in this table are stored in a
  16635. 16-bit fixed-point format with an unsigned integer part in the high-order 4 bits and
  16636. a fractional part in the low-order 12 bits.
  16637.  
  16638. •••Refer to Figure 15.•••
  16639.  
  16640. Figure 15–Style Codes
  16641.  
  16642. The style-mapping table and its associated tables are used by the LaserWriter driver
  16643. and are described in the Apple LaserWriter Reference.
  16644.  
  16645. The kerning table, like the family character-width table, is actually a number of
  16646. kerning tables (see Figure 16).
  16647.  
  16648. •••Refer to Figure 16.•••
  16649.  
  16650. Figure 16–Kerning Table
  16651.  
  16652. Each kerning table is preceded by a style code; stored in the low-order byte of the
  16653. word, this style information has the same format shown in Figure 15 above. The number
  16654. of entries in the table follows the style word (see Figure 17).
  16655.  
  16656. •••Refer to Figure 17.•••
  16657.  
  16658. Figure 17–Structure of a Kerning Table
  16659.  
  16660. The entries in each kerning table (shown in Figure 18) consist of a pair of characters
  16661. followed by a kerning offset for a hypothetical one-point font. This value, represented
  16662. by an integer part in the high-order 4 bits and a fractional part in the low-order 12
  16663. bits, is multiplied by the size of the font to obtain the actual offset.
  16664.  
  16665. •••Refer to Figure 18.•••
  16666.  
  16667. Figure 18–Kerning Table Entry
  16668.  
  16669. Note:  The extensions to the Font Manager described in the following paragraphs
  16670.        were originally documented in Inside Macintosh, Volume V.  As such,
  16671.        this information refers to the Macintosh SE and Macintosh II ROMs and
  16672.        System file version 4.1 and later.
  16673.  
  16674. For Macintosh II only, bits 8 and 9 of the font style word within each font association
  16675. table specify the font depth; they must contain the same value as bits 2 and 3 of the
  16676. fontType field of the font record.  All other undefined bits remain 0.
  16677.  
  16678. A font family is stored as a resource of type 'FOND', and with the Macintosh II, it’s
  16679. format has been extended.  The new format is the following (with extension fields
  16680. indicated by asterisks):
  16681.  
  16682.   Number of bytes    Contents
  16683.  
  16684.       2 bytes        FONDFlags field of family record
  16685.       2 bytes        FONDFamID field of family record
  16686.       2 bytes        FONDFirst field of family record
  16687.       2 bytes        FONDLast field of family record
  16688.       2 bytes        FONDAscent field of family record
  16689.       2 bytes        FONDDescent field of family record
  16690.       2 bytes        FONDLeading field of family record
  16691.       2 bytes        FONDWidMax field of family record
  16692.       4 bytes        FONDWTabOff of family record
  16693.       4 bytes        FONDKernOff of family record
  16694.       4 bytes        FONDStylOff of family record
  16695.       24 bytes       FONDProperty field of family record
  16696.       4 bytes        FONDIntl field of family record
  16697.       2 bytes        *Version number ($02)
  16698.       m bytes        FONDAssoc field of family record (variable length)
  16699.       2 bytes        *Number of offsets minus 1
  16700.       4 bytes        *Offset to bounding box table
  16701.       n bytes        *Bounding box table
  16702.       p bytes        FONDWidTable field of family record (variable length)
  16703.       q bytes        FONDStylTab field of family record (variable length)
  16704.       r bytes        FONDKerntab field of family record (variable length)
  16705.  
  16706. The bounding box table has an entry for each style available in the family.  The
  16707. table as a whole has this form:
  16708.  
  16709.   Number of bytes    Contents
  16710.  
  16711.       2 bytes        Number of entries minus 1
  16712.       10 bytes       First entry
  16713.       10 bytes       Second entry . . .
  16714.  
  16715. Each bounding box entry has this form, giving the bounding box position with respect
  16716. to the origin of the characters:
  16717.  
  16718.   Number of bytes    Contents
  16719.  
  16720.       2 bytes        Style word
  16721.       2 bytes        Lower left x coordinate
  16722.       2 bytes        Lower left y coordinate
  16723.       2 bytes        Upper right x coordinate
  16724.       2 bytes        Upper right y coordinate
  16725.  
  16726. Note:  The extensions to the Font Manager described in the following paragraphs
  16727.        were originally documented in Inside Macintosh, Volume IV.  As such,
  16728.        this information refers to the 128K ROMs and System file version 3.2
  16729.        and later.
  16730.  
  16731. æKY FMetricRec
  16732. æFp Fonts.p
  16733. æT RECORD
  16734. æC FMetricRec = RECORD
  16735.    ascent: Fixed;                          {base line to top}
  16736.    descent: Fixed;                         {base line to bottom}
  16737.    leading: Fixed;                         {leading between lines}
  16738.    widMax: Fixed;                          {maximum character width}
  16739.    wTabHandle: Handle;                     {handle to font width table}
  16740.    END;
  16741.  
  16742. æKY FMInput
  16743. æFp Fonts.p
  16744. æT PACKED RECORD
  16745. æC FMInput = PACKED RECORD
  16746.    family: INTEGER;
  16747.    size: INTEGER;
  16748.    face: Style;
  16749.    needBits: BOOLEAN;
  16750.    device: INTEGER;
  16751.    numer: Point;
  16752.    denom: Point;
  16753.    END;
  16754. _______________________________________________________________________________
  16755.  
  16756. »COMMUNICATION BETWEEN QUICKDRAW AND THE FONT MANAGER
  16757. _______________________________________________________________________________
  16758.  
  16759. This section describes the data structures that allow QuickDraw and the Font Manager
  16760. to exchange information. It also discusses the communication that may occur between
  16761. the Font Manager and the driver of the device on which the characters are being drawn
  16762. or printed. You can skip this section if you want to change fonts, character style,
  16763. and font sizes by calling QuickDraw and aren’t interested in the lower-level data
  16764. structures and routines of the Font Manager. To understand this section fully, you’ll
  16765. have to be familiar with device drivers and the Device Manager.
  16766.  
  16767. Whenever you call a QuickDraw routine that does anything with text, QuickDraw requests
  16768. information from the Font Manager about the characters. The Font Manager performs any
  16769. necessary calculations and returns the requested information to QuickDraw. As illustrated
  16770. in Figure 21, this information exchange occurs via two data structures, a font input
  16771. record (type FMInput) and a font output record (type FMOutput).
  16772.  
  16773. First, QuickDraw passes the Font Manager a font input record:
  16774.  
  16775. TYPE FMInput = PACKED RECORD
  16776.                  family:    INTEGER;  {font number}
  16777.                  size:      INTEGER;  {font size}
  16778.                  face:      Style;    {character style}
  16779.                  needBits:  BOOLEAN;  {TRUE if drawing}
  16780.                  device:    INTEGER;  {device-specific information}
  16781.                  numer:     Point;    {numerators of scaling factors}
  16782.                  denom:     Point     {denominators of scaling factors}
  16783.                END;
  16784.  
  16785. The first three fields contain the font number, size, and character style that QuickDraw
  16786. wants to use.
  16787.  
  16788. The needBits field indicates whether the characters actually will be drawn or not. If
  16789. the characters are being drawn, all of the information describing the font, including
  16790. the bit image comprising the characters, will be read into memory. If the characters
  16791. aren’t being drawn and there’s a resource consisting of only the character widths and
  16792. general font information, that resource will be read instead.
  16793.  
  16794. The high-order byte of the device field contains a device driver reference number.
  16795. From the driver reference number, the Font Manager can determine the optimum stylistic
  16796. variations on the font to produce the highest-quality printing or drawing available
  16797. on a device (as explained below). The low-order byte of the device field is ignored
  16798. by the Font Manager but may contain information used by the device driver.
  16799.  
  16800. •••Refer to Figure 21.•••
  16801.  
  16802. Figure 21–Communication About Fonts
  16803.  
  16804. The numer and denom fields contain the scaling factors to be used; numer.v divided by
  16805. denom.v gives the vertical scaling, and numer.h divided by denom.h gives the horizontal
  16806. scaling.
  16807.  
  16808. The Font Manager takes the font input record and asks the Resource Manager for the
  16809. font. If the requested size isn’t available, the Font Manager scales another size to
  16810. match (as described under “Font Scaling”).
  16811.  
  16812. Then the Font Manager gets the font characterization table via the device field. If
  16813. the high-order byte of the device field is 0, the Font Manager gets the screen’s font
  16814. characterization table (which is stored in the Font Manager). If the high-order byte
  16815. of the device field is nonzero, the Font Manager calls the status routine of the
  16816. device driver having that reference number, and the status routine returns a font
  16817. characterization table. The status routine may use the value of the low-order byte of
  16818. the device field to determine the font characterization table it should return.
  16819.  
  16820. Note:  If you want to make your own calls to the device driver’s Status
  16821.        function, the reference number must be the driver reference number
  16822.        from the font input record’s device field, csCode must be 8, csParam
  16823.        must be a pointer to where the device driver should put the font
  16824.        characterization table, and csParam+4 must be an integer containing
  16825.        the value of the font input record’s device field.
  16826.  
  16827. Figure 22 shows the structure of a font characterization table and, on the right, the
  16828. values it contains for the Macintosh screen.
  16829.  
  16830. •••Refer to Figure 22.•••
  16831.  
  16832. Figure 22–Font Characterization Table
  16833.  
  16834. The first two words of the font characterization table contain the approximate number
  16835. of dots per inch on the device. These values are only used for scaling between devices;
  16836. they don’t necessarily correspond to a device’s actual resolution.
  16837.  
  16838. The remainder of the table consists of three-byte triplets providing information
  16839. about the different stylistic variations. For all but the triplet defining the underline
  16840. characteristics:
  16841.  
  16842.   •  The first byte in the triplet indicates which byte beyond the bold
  16843.      field of the font output record (see below) is affected by the triplet.
  16844.   •  The second byte contains the amount to be stored in the affected field.
  16845.   •  The third byte indicates the amount by which the extra field of the
  16846.      font output record is to be incremented (starting from 0).
  16847.  
  16848. The triplet defining the underline characteristics indicates the amount by which the
  16849. font output record’s ulOffset, ulShadow, and ulThick fields
  16850. (respectively) should be incremented.
  16851.  
  16852. æKY FMSwapFont
  16853. æFp Fonts.p
  16854. æT FUNCTION
  16855. æTN $A901
  16856. æD FUNCTION FMSwapFont(inRec: FMInput): FMOutPtr;
  16857. æDT myVariable := FMSwapFont(inRec);
  16858. æMM   
  16859. æRI FMSwapFont function I-223
  16860. æC 
  16861. The following low-level routine is called by QuickDraw and won’t normally be used by
  16862. an application directly, but it may be of interest to advanced programmers who want
  16863. to bypass the QuickDraw routines that deal with text.
  16864.  
  16865. FUNCTION FMSwapFont (inRec:  FMInput) :  FMOutPtr;
  16866.  
  16867. FMSwapFont returns a pointer to a font output record containing the size, style, and
  16868. other information about an adapted version of the font requested in the given font
  16869. input record. (Font input and output records are explained in the following section.)
  16870. FMSwapFont is called by QuickDraw every time a QuickDraw routine that does anything
  16871. with text is used. If you want to call FMSwapFont yourself, you must build a font
  16872. input record and then use the pointer returned by FMSwapFont to access the resulting
  16873. font output record.
  16874.  
  16875. æKY FontAssoc
  16876. æFp Fonts.p
  16877. æT RECORD
  16878. æC FontAssoc = RECORD
  16879.    numAssoc: INTEGER;                      {number of entries - 1}
  16880.    END;
  16881.  
  16882. æKY FontMetrics
  16883. æFp Fonts.p
  16884. æT PROCEDURE
  16885. æTN $A835
  16886. æD PROCEDURE FontMetrics(theMetrics: FMetricRec);
  16887. æDT FontMetrics(theMetrics);
  16888. æMM   
  16889. æRI FontMetrics procedure  IV-32
  16890. æC  
  16891. Note:  The extensions to the Font Manager described in the following paragraphs
  16892.        were originally documented in Inside Macintosh, Volume IV.  As such,
  16893.        this information refers to the 128K ROMs and System file version 3.2
  16894.        and later.
  16895.  
  16896. To improve the speed and readability of text display in your application, use the
  16897. SetFractEnable and SetFScaleDisable procedures to enable fractional character widths
  16898. and disable font scaling. Certain applications do not work properly when fractional
  16899. character widths are used and font scaling is disabled, so these features are turned
  16900. off by default.
  16901.  
  16902. The FontMetrics function is much like QuickDraw’s GetFontInfo function except that it
  16903. returns fixed-point values, letting you draw characters in more precise locations on
  16904. the screen.
  16905.  
  16906. If there’s a 'FOND' resource associated with the most recently drawn font, making the
  16907. font resource purgeable or unpurgeable with the SetFontLock procedure will make the
  16908. 'FOND' resource resource purgeable or unpurgeable as well.
  16909.  
  16910. PROCEDURE FontMetrics (VAR theMetrics:  FMetricRec);
  16911.  
  16912. FontMetrics is similar to the QuickDraw procedure GetFontInfo except that it returns
  16913. fixed-point values for greater accuracy in high-resolution printing.
  16914.  
  16915. The FMetricRec data structure is defined as follows:
  16916.  
  16917. TYPE FMetricRec = RECORD
  16918.                     ascent:      Fixed;    {ascent}
  16919.                     descent:     Fixed;    {descent}
  16920.                     leading:     Fixed;    {leading}
  16921.                     widMax:      Fixed;    {maximum character width}
  16922.                     wTabHandle:  Handle;   {handle to global width table}
  16923.                   END;
  16924.  
  16925. Ascent, descent, leading, and widMax are identical in function to their counterparts
  16926. in GetFontInfo. WTabHandle is a handle to the global width table
  16927. (described below).
  16928.  
  16929. æKY FontRec
  16930. æFp Fonts.p
  16931. æT RECORD
  16932. æC FontRec = RECORD
  16933.    fontType: INTEGER;                      {font type}
  16934.    firstChar: INTEGER;                     {ASCII code of first character}
  16935.    lastChar: INTEGER;                      {ASCII code of last character}
  16936.    widMax: INTEGER;                        {maximum character width}
  16937.    kernMax: INTEGER;                       {negative of maximum character kern}
  16938.    nDescent: INTEGER;                      {negative of descent}
  16939.    fRectWidth: INTEGER;                    {width of font rectangle}
  16940.    fRectHeight: INTEGER;                   {height of font rectangle}
  16941.    owTLoc: INTEGER;                        {offset to offset/width table}
  16942.    ascent: INTEGER;                        {ascent}
  16943.    descent: INTEGER;                       {descent}
  16944.    leading: INTEGER;                       {leading}
  16945.    rowWords: INTEGER;                      {row width of bit image / 2 }
  16946.    END;
  16947.  
  16948.  
  16949. »Font Records
  16950.  
  16951. The information describing a font is contained in a data structure called a font
  16952. record, which contains the following:
  16953.  
  16954.   •  the font type (fixed-width or proportional)
  16955.   •  the ASCII code of the first character and the last character in the font
  16956.   •  the maximum character width and maximum amount any character kerns
  16957.   •  the font height, ascent, descent, and leading
  16958.   •  the bit image of the font
  16959.   •  a location table, which is an array of words specifying the location
  16960.      of each character image within the bit image
  16961.   •  an offset/width table, which is an array of words specifying the
  16962.      character offset and character width for each character in the font
  16963.  
  16964. For every character, the location table contains a word that specifies the bit offset
  16965. to the location of that character’s image in the bit image. The entry for a character
  16966. missing from the font contains the same value as the entry for the next character.
  16967. The last word of the table contains the offset to one bit beyond the end of the bit
  16968. image (that is, beyond the character image for the missing symbol). The image width
  16969. of each character is determined from the location table by subtracting the bit offset
  16970. to that character from the bit offset to the next character in the table.
  16971.  
  16972. There’s also one word in the offset/width table for every character:  The high-order
  16973. byte specifies the character offset and the low order byte specifies the character
  16974. width. Missing characters are flagged in this table by a word value of –1. The last
  16975. word is also –1, indicating the end of the table.
  16976.  
  16977. Note:  The 64K ROM version of the Resource Manager limits the total space
  16978.        occupied by the bit image, location table, offset/width table, and
  16979.        character-width and image-height tables to 32K bytes. For this reason,
  16980.        the practical limit on the font size of a full font is about 40 points.
  16981.  
  16982. Figure 9 illustrates a sample location table and offset/width table corresponding to
  16983. the bit image in Figure 8 above.
  16984.  
  16985. A font record is referred to by a handle that you can get by calling the FMSwapFont
  16986. function or the Resource Manager function GetResource. The data type for a font
  16987. record is as follows:
  16988.  
  16989. TYPE FontRec = RECORD
  16990.                  fontType:     INTEGER;    {font type}
  16991.                  firstChar:    INTEGER;    {ASCII code of first character}
  16992.                  lastChar:     INTEGER;    {ASCII code of last character}
  16993.                  widMax:       INTEGER;    {maximum character width}
  16994.                  kernMax:      INTEGER;    {negative of maximum character kern}
  16995.                  nDescent:     INTEGER;    {negative of descent}
  16996.                  fRectWidth:   INTEGER;    {width of font rectangle}
  16997.                  fRectHeight:  INTEGER;    {height of font rectangle}
  16998.                  owTLoc:       INTEGER;    {offset to offset/width table}
  16999.                  ascent:       INTEGER;    {ascent}
  17000.                  descent:      INTEGER;    {descent}
  17001.                  leading:      INTEGER;    {leading}
  17002.                  rowWords:     INTEGER;    {row width of bit image / 2}
  17003.                { bitImage:     ARRAY[1..rowWords,1..fRectHeight] OF INTEGER; }
  17004.                                            {bit image}
  17005.                { locTable:     ARRAY[firstChar..lastChar+2] OF INTEGER; }
  17006.                                            {location table}
  17007.                { owTable:      ARRAY[firstChar..lastChar+2] OF INTEGER; }
  17008.                                            {offset/width table}
  17009.                END;
  17010.  
  17011. Note:  The variable-length arrays appear as comments because they’re
  17012.        not valid Pascal syntax; they’re used only as conceptual aids.
  17013.  
  17014. •••Refer to Figure 9.•••
  17015.  
  17016. Figure 9–Sample Location Table and Offset/Width Table
  17017.  
  17018. The fontType field must contain one of the following predefined constants:
  17019.  
  17020. CONST  propFont   = $9000;    {proportional font}
  17021.        fixedFont  = $B000;    {fixed-width font}
  17022.  
  17023. The values in the widMax, kernMax, nDescent, fRectWidth, fRectHeight, ascent, descent,
  17024. and leading fields all specify a number of pixels.
  17025.  
  17026. KernMax indicates the largest number of pixels any character kerns, that is, the
  17027. distance from the character origin to the left edge of the font rectangle. It should
  17028. always be 0 or negative, since the kerned pixels are to the left of the character
  17029. origin. NDescent is the negative of the descent (the distance from the character
  17030. origin to the bottom of the font rectangle).
  17031.  
  17032. The owTLoc field contains a word offset from itself to the offset/width table; it’s
  17033. equivalent to
  17034.  
  17035.   4 + (rowWords * fRectHeight) + (lastChar–firstChar+3) + 1
  17036.  
  17037. Warning:  Remember, the offset and row width in a font record are
  17038.           given in words, not bytes.
  17039.  
  17040. Assembly-language note:  The global variable ROMFont0 contains a handle
  17041.                          to the font record for the system font.
  17042.  
  17043. Every size of a font is stored as a separate resource.  The resource type for a font
  17044. is 'FONT'.  The resource data for a font is simply a font record:
  17045.  
  17046.   Number of bytes    Contents
  17047.  
  17048.       2 bytes        FontType field of font record
  17049.       2 bytes        FirstChar field of font record
  17050.       2 bytes        LastChar field of font record
  17051.       2 bytes        WidMax field of font record
  17052.       2 bytes        KernMax field of font record
  17053.       2 bytes        NDescent field of font record
  17054.       2 bytes        FRectWidth field of font record
  17055.       2 bytes        FRectHeight field of font record
  17056.       2 bytes        OWTLoc field of font record
  17057.       2 bytes        Ascent field of font record
  17058.       2 bytes        Descent field of font record
  17059.       2 bytes        Leading field of font record
  17060.       2 bytes        RowWords field of font record
  17061.       n bytes        Bit image of font
  17062.                          n = 2 * rowWords * fRectHeight
  17063.       m bytes        Location table of font
  17064.                          m = 2 * (lastChar–firstChar+3)
  17065.       m bytes        Offset/width table of font
  17066.                          m = 2 * (lastChar–firstChar+3)
  17067.  
  17068. As shown in Figure 10, the resource ID of a font has the following format:  Bits 0-6
  17069. are the font size, bits 7-14 are the font number, and bit 15 is 0. Thus the resource
  17070. ID corresponding to a given font number and size is
  17071.  
  17072.   (128 * font number) + font size
  17073.  
  17074. •••Refer to Technical Note #245:•••
  17075.  
  17076. Since 0 is not a valid font size, the resource ID having 0 in the size field is used
  17077. to provide only the name of the font:  The name of the resource is the font name. For
  17078. example, for a font named Griffin and numbered 200, the resource naming the font
  17079. would have a resource ID of 25600 and the resource name
  17080. 'Griffin'. Size 10 of that font would be stored in a resource numbered 25610.
  17081.  
  17082. •••Refer to Figure 10.•••
  17083.  
  17084. Figure 10–Resource ID for a Font
  17085.  
  17086. The resource type 'FRSV' is reserved by the Font Manager; it identifies fonts used by
  17087. the system. Fonts whose resource IDs are contained in a 'FRSV' resource 1 will not be
  17088. removed from the system resource file by the Font/DA Mover. The format of a 'FRSV'
  17089. resource is as follows:
  17090.  
  17091.   Number of bytes    Contents
  17092.  
  17093.       2 bytes        Number of font resource IDs
  17094.       n * 2 bytes    n font resource IDs
  17095.  
  17096. æKY GetFNum
  17097. æFp Fonts.p
  17098. æT PROCEDURE
  17099. æTN $A900
  17100. æD PROCEDURE GetFNum(theName: Str255;VAR familyID: INTEGER);
  17101. æDT GetFNum(theName,familyID);
  17102. æMM 
  17103. æRT 191
  17104. æRI GetFNum procedure I-223
  17105. æC  
  17106. Warning:  Before returning, the routines in this section issue the Resource
  17107.           Manager call SetResLoad(TRUE). If your program previously called
  17108.           SetResLoad(FALSE) and you still want that to be in effect after
  17109.           calling one of these Font Manager routines, you’ll have to call
  17110.           SetResLoad(FALSE) again.
  17111.  
  17112.  
  17113. GetFNum returns in theNum the font number for the font having the given fontName. If
  17114. there’s no such font, GetFNum returns 0.
  17115.  
  17116. æKY GetFontName
  17117. æFp Fonts.p
  17118. æT PROCEDURE
  17119. æTN $A8FF
  17120. æD PROCEDURE GetFontName(familyID: INTEGER;VAR theName: Str255);
  17121. æDT GetFontName(familyID,theName);
  17122. æMM 
  17123. æRT 191
  17124. æRI GetFontName procedure I-223
  17125. æC  
  17126. Warning:  Before returning, the routines in this section issue the Resource
  17127.           Manager call SetResLoad(TRUE). If your program previously called
  17128.           SetResLoad(FALSE) and you still want that to be in effect after
  17129.           calling one of these Font Manager routines, you’ll have to call
  17130.           SetResLoad(FALSE) again.
  17131.  
  17132. PROCEDURE GetFontName (fontNum:  INTEGER; VAR theName:  Str255);
  17133.  
  17134. Assembly-language note:  The macro you invoke to call GetFontName from
  17135.                          assembly language is named _GetFName.
  17136.  
  17137. GetFontName returns in theName the name of the font having the font number fontNum.
  17138. If there’s no such font, GetFontName returns the empty string.
  17139.  
  17140. æKY InitFonts
  17141. æFp Fonts.p
  17142. æT PROCEDURE
  17143. æTN $A8FE
  17144. æD PROCEDURE InitFonts;
  17145. æDT InitFonts;
  17146. æMM 
  17147. æRT 72
  17148. æRI InitFonts procedure I-222, P-31, 95, 101, 107, 112, 118, 174
  17149. æC  
  17150. InitFonts initializes the Font Manager. If the system font isn’t already in memory,
  17151. InitFonts reads it into memory. Call this procedure once before all other Font Manager
  17152. routines or any Toolbox routine that will call the Font Manager.
  17153.  
  17154. æKY KernEntry
  17155. æFp Fonts.p
  17156. æT RECORD
  17157. æC KernEntry = RECORD
  17158.    kernLength: INTEGER;                    {length of this entry}
  17159.    kernStyle: INTEGER;                     {style the entry applies to}
  17160.    END;
  17161.  
  17162. æKY KernPair
  17163. æFp Fonts.p
  17164. æT RECORD
  17165. æC KernPair = RECORD
  17166.    kernFirst: CHAR;                        {1st character of kerned pair}
  17167.    kernSecond: CHAR;                       {2nd character of kerned pair}
  17168.    kernWidth: INTEGER;                     {kerning in 1pt fixed format}
  17169.    END;
  17170.  
  17171. æKY KernTable
  17172. æFp Fonts.p
  17173. æT RECORD
  17174. æC KernTable = RECORD
  17175.    numKerns: INTEGER;                      {number of kerning entries}
  17176.    END;
  17177.  
  17178. æKY mobile
  17179. æFp Fonts.p
  17180. æC mobile = 24;
  17181.  
  17182. æKY NameTable
  17183. æFp Fonts.p
  17184. æT RECORD
  17185. æC NameTable = RECORD
  17186.    stringCount: INTEGER;
  17187.    baseFontName: Str255;
  17188.    END;
  17189.  
  17190. æKY propFont,prpFntH,prpFntW,prpFntHW,fixedFont,fxdFntH,fxdFntW,fxdFntHW,fontWid
  17191. æFp Fonts.p
  17192. æC 
  17193.   { Font types [Volume IV addition]}
  17194.  
  17195.   propFont     = $9000;  {proportional font}
  17196.   prpFntH      = $9001;  { with height table}
  17197.   prpFntW      = $9002;  { with width table}
  17198.   prpFntHW     = $9003;  { with height & width tables}
  17199.  
  17200.   fixedFont    = $B000;  {fixed-width font}
  17201.   fxdFntH      = $B001;  { with height table}
  17202.   fxdFntW      = $B002;  { with width table}
  17203.   fxdFntHW     = $B003;  { with height & width tables}
  17204.  
  17205.   fontWid      = $ACB0;  {font width data:  64K ROM only}
  17206.  
  17207. æKY RealFont
  17208. æFp Fonts.p
  17209. æT FUNCTION
  17210. æTN $A902
  17211. æD FUNCTION RealFont(fontNum: INTEGER;size: INTEGER): BOOLEAN;
  17212. æDT myVariable := RealFont(fontNum,size);
  17213. æMM   
  17214. æRI RealFont function I-223
  17215. æC  
  17216. Warning:  Before returning, the routines in this section issue the Resource
  17217.           Manager call SetResLoad(TRUE). If your program previously called
  17218.           SetResLoad(FALSE) and you still want that to be in effect after
  17219.           calling one of these Font Manager routines, you’ll have to call
  17220.           SetResLoad(FALSE) again.
  17221.  
  17222. RealFont returns TRUE if the font having the font number fontNum is available in the
  17223. given size in a resource file, or FALSE if the font has to be scaled to that size.
  17224.  
  17225. Note:  RealFont will always return FALSE if you pass applFont in fontNum.
  17226.        To find out if the application font is available in a particular
  17227.        size, call GetFontName and then GetFNum to get the actual font
  17228.        number for the application font, and then call RealFont with that number.
  17229.  
  17230. æKY SetFontLock
  17231. æFp Fonts.p
  17232. æT PROCEDURE
  17233. æTN $A903
  17234. æD PROCEDURE SetFontLock(lockFlag: BOOLEAN);
  17235. æDT SetFontLock(lockFlag);
  17236. æMM   
  17237. æRI SetFontLock procedure I-223
  17238. æC  
  17239. SetFontLock applies to the font in which text was most recently drawn. If lockFlag is
  17240. TRUE, SetFontLock makes the font unpurgeable (reading it into memory if it isn’t
  17241. already there). If lockFlag is FALSE, it releases the memory occupied by the font 
  17242. (by calling the Resource Manager procedure ReleaseResource).
  17243. Since fonts are normally purgeable, this procedure is useful for making a font temporarily
  17244. unpurgeable.
  17245.  
  17246. æKY SetFractEnable
  17247. æFp Fonts.p
  17248. æT PROCEDURE
  17249. æD PROCEDURE SetFractEnable(fractEnable: BOOLEAN);
  17250. æDT SetFractEnable(fractEnable);
  17251. æRT 72
  17252. æRI SetFractEnable  IV-32 routine  V-180
  17253. æC  
  17254. Note:  The extensions to the Font Manager described in the following paragraphs
  17255.        were originally documented in Inside Macintosh, Volume IV.  As such,
  17256.        this information refers to the 128K ROMs and System file version 3.2
  17257.        and later.
  17258.  
  17259. SetFractEnable lets you enable or disable fractional character widths. If fractEnable
  17260. is TRUE, fractional character widths are enabled; if it’s FALSE, the Font Manager
  17261. uses integer widths. To ensure compatibility with existing applications, fractional
  17262. character widths are disabled by default.
  17263.  
  17264. SetFractEnable, which was not in the 128K ROM (but was available in the Pascal interfaces)
  17265. has been added to both the Macintosh SE and Macintosh II ROMs.
  17266.  
  17267. Assembly-language note:   Assembly-language programmers should call
  17268.                           SetFractEnable rather than change the value
  17269.                           of the global variable FractEnable.
  17270.  
  17271. æKY SetFScaleDisable
  17272. æFp Fonts.p
  17273. æT PROCEDURE
  17274. æTN $A834
  17275. æD PROCEDURE SetFScaleDisable(fscaleDisable: BOOLEAN);
  17276. æDT SetFScaleDisable(fscaleDisable);
  17277. æRI SetFScaleDisable procedure  IV-32
  17278. æC  
  17279. Note:  The extensions to the Font Manager described in the following paragraphs
  17280.        were originally documented in Inside Macintosh, Volume IV.  As such,
  17281.        this information refers to the 128K ROMs and System file version 3.2
  17282.        and later.
  17283.  
  17284. SetFScaleDisable lets you disable or enable font scaling. If fontScaleDisable is
  17285. TRUE, font scaling is disabled and the Font Manager returns an unscaled font with
  17286. more space around the characters; if it’s FALSE, the Font Manager scales fonts. To
  17287. ensure compatibility with existing applications, the Font Manager defaults to scaling
  17288. fonts.
  17289.  
  17290. Assembly-language note:  All programmers should use the SetFScaleDisable
  17291.                          procedure to disable and enable font scaling. In
  17292.                          particular, setting the global variable FScaleDisable
  17293.                          is insufficient.
  17294.  
  17295. æKY StyleTable
  17296. æFp Fonts.p
  17297. æT RECORD
  17298. æC StyleTable = RECORD
  17299.    fontClass: INTEGER;
  17300.    offset: LONGINT;
  17301.    reserved: LONGINT;
  17302.    indexes: ARRAY [0..47] OF SignedByte;
  17303.    END;
  17304.  
  17305. æKY systemFont,applFont,newYork,geneva,monaco,venice,london,athens,sanFran,toronto,cairo,losAngeles,times,helvetica,courier,symbol,taliesin
  17306. æFp Fonts.p
  17307. æC 
  17308. _______________________________________________________________________________
  17309.  
  17310. »FONT NUMBERS
  17311. _______________________________________________________________________________
  17312.  
  17313. Note:  The information on Font Numbers described in the following
  17314.        paragraphs was originally documented in Inside Macintosh, Volume I.
  17315.  
  17316. The Font Manager includes the following font numbers for identifying system-defined
  17317. fonts:
  17318.  
  17319. CONST  systemFont  = 0;    {system font}
  17320.        applFont    = 1;    {application font}
  17321.        newYork     = 2;
  17322.        geneva      = 3;
  17323.        monaco      = 4;
  17324.        venice      = 5;
  17325.        london      = 6;
  17326.        athens      = 7;
  17327.        sanFran     = 8;
  17328.        toronto     = 9;
  17329.        cairo       = 11;
  17330.        losAngeles  = 12;
  17331.        times       = 20;
  17332.        helvetica   = 21;
  17333.        courier     = 22;
  17334.        symbol      = 23;
  17335.        taliesin    = 24;
  17336.  
  17337. The system font is so called because it’s the font used by the system (for drawing
  17338. menu titles and commands in menus, for example). The name of the system font is
  17339. Chicago. The size of text drawn by the system in this font is fixed at 12 points
  17340. (called the system font size).
  17341.  
  17342. The application font is the font your application will use unless you specify otherwise.
  17343. Unlike the system font, the application font isn’t a separate font, but is essentially
  17344. a reference to another font—Geneva, by default. (The application font number is
  17345. determined by a value that you can set in parameter RAM; see the Operating System
  17346. Utilities chapter for more information.)
  17347.  
  17348. Assembly-language note:  You can get the application font number
  17349.                          from the global variable ApFontID.
  17350.  
  17351. æKY WidEntry
  17352. æFp Fonts.p
  17353. æT RECORD
  17354. æC WidEntry = RECORD
  17355.    numWidths: INTEGER;                     {number of entries - 1}
  17356.    END;
  17357.  
  17358. æKY WidthTable
  17359. æFp Fonts.p
  17360. æT PACKED RECORD
  17361. æC WidthTable = PACKED RECORD
  17362.    tabData: ARRAY [1..256] OF Fixed;       {character widths}
  17363.    tabFont: Handle;                        {font record used to build table}
  17364.    sExtra: LONGINT;                        {space extra used for table}
  17365.    style: LONGINT;                         {extra due to style}
  17366.    fID: INTEGER;                           {font family ID}
  17367.    fSize: INTEGER;                         {font size request}
  17368.    face: INTEGER;                          {style (face) request}
  17369.    device: INTEGER;                        {device requested}
  17370.    inNumer: Point;                         {scale factors requested}
  17371.    inDenom: Point;                         {scale factors requested}
  17372.    aFID: INTEGER;                          {actual font family ID for table}
  17373.    fHand: Handle;                          {family record used to build up table}
  17374.    usedFam: BOOLEAN;                       {used fixed point family widths}
  17375.    aFace: Byte;                            {actual face produced}
  17376.    vOutput: INTEGER;                       {vertical scale output value}
  17377.    hOutput: INTEGER;                       {horizontal scale output value}
  17378.    vFactor: INTEGER;                       {vertical scale output value}
  17379.    hFactor: INTEGER;                       {horizontal scale output value}
  17380.    aSize: INTEGER;                         {actual size of actual font used}
  17381.    tabSize: INTEGER;                       {total size of table}
  17382.    END;
  17383.  
  17384.  
  17385. »Global Width Tables
  17386.  
  17387. Note:  The extensions to the Font Manager described in the following paragraphs
  17388.        were originally documented in Inside Macintosh, Volume IV.  As such,
  17389.        this information refers to the 128K ROMs and System file version 3.2
  17390.        and later.
  17391.  
  17392. The Font Manager communicates fractional character widths to QuickDraw via a global
  17393. width table, a data structure allocated in the system heap. A handle to the global
  17394. width table is returned by the FontMetrics procedure. The format of the global width
  17395. table is follows:
  17396.  
  17397. TYPE WidthTable = RECORD
  17398.                     tabData:  ARRAY[1..256] OF Fixed; { character widths}
  17399.                     tabFont:  Handle;   {font record used to build table}
  17400.                     sExtra:   LONGINT;  {space extra used for table}
  17401.                     style:    LONGINT;  {extra due to style}
  17402.                     fID:      INTEGER;  {font family ID}
  17403.                     fSize:    INTEGER;  {font size request}
  17404.                     face:     INTEGER;  {style (face) request}
  17405.                     device:   INTEGER;  {device requested}
  17406.                     inNumer:  Point;    {numerators of scaling factors}
  17407.                     inDenom:  Point;    {denominators of scaling factors}
  17408.                     aFID:     INTEGER;  {actual font family ID for table}
  17409.                     fHand:    handle;   {family record used to build table}
  17410.                     usedFam:  BOOLEAN;  {used fixed-point family widths}
  17411.                     aFace:    Byte;     {actual face produced}
  17412.                     vOutput:  INTEGER;  {vertical factor for expanding }
  17413.                                         { characters}
  17414.                     hOutput:  INTEGER;  {horizontal factor for expanding }
  17415.                                         { characters}
  17416.                     vFactor:  INTEGER;  {not used}
  17417.                     hFactor:  INTEGER;  {horizontal factor for increasing }
  17418.                                         { character widths}
  17419.                     aSize:    INTEGER;  {actual size of actual font used}
  17420.                     tabSize:  INTEGER   {total size of table}
  17421.                   END;
  17422.  
  17423. TabData is an array containing a character width for each of the 255 possible characters
  17424. in a font, plus one long word for the font’s missing symbol. The widths are stored in
  17425. the standard 32-bit fixed-point format. If a character is missing, its entry contains
  17426. the width of the missing symbol. (For efficiency, the Font Manager will store up to
  17427. 12 recently used global width tables.) InNumer and inDenom contain the vertical and
  17428. horizontal scaling factors copied from the font input record.
  17429.  
  17430. Scaling is effected in two ways:  by expanding characters of the chosen font and by
  17431. artificially increasing the widths of the chosen font in the width table. HOutput and
  17432. vOutput give the factors by which characters are to be expanded horizontally and
  17433. vertically. HFactor is the factor by which the widths of the chosen font, after
  17434. stylistic variations, have been increased. (VFactor is not used.) Thus, multiplying
  17435. hOutput and vOutput by hFactor and vFactor gives the true font scaling; the product
  17436. of hOutput and an entry in the width table is that character’s true scaled width.
  17437. HOutput,vOutput, hFactor, and vFactor are all 16-bit fixed-point numbers, with an
  17438. integer part in the high-order byte and a fractional part in the low-order byte.
  17439.  
  17440. If font scaling has been enabled, hFactor and vFactor both have a value of 1. In any
  17441. case, hOutput, vOutput, hFactor, and vFactor are adjusted so that the values of
  17442. hFactor and vFactor lie between 1 and 2, including 1.
  17443.  
  17444. Assembly-language note:  A handle to the global width table is contained
  17445.                          in the global variable WidthTabHandle. A pointer
  17446.                          to the table is contained in the global variable
  17447.                          WidthPtr; it’s reliable immediately after a call
  17448.                          to FMSwapFont but, like all pointers, may become
  17449.                          invalid after a call to the Memory Manager.
  17450.  
  17451.                          The global variable WidthListHand is a handle to a
  17452.                          list of handles to up to 12 recently-used width
  17453.                          tables. You can scan this list, looking for width
  17454.                          tables that match the family number, size, and style
  17455.                          of the font you wish to measure. If you reach a width
  17456.                          handle that’s equal to –1, that width table is
  17457.                          invalid, and you must make an FMSwapFont call to
  17458.                          get a valid one. When you reach a handle that’s zero,
  17459.                          you’ve reached the end of the list.
  17460.  
  17461.                          You should not use the global width table when
  17462.                          special international interface software is being
  17463.                          used to accommodate non-Roman alphabets. You can
  17464.                          recognize such software by looking at the global
  17465.                          variable IntlSpec; if it’s greater than 0, special
  17466.                          international software is installed. If your
  17467.                          application uses non-Roman alphabets, write to
  17468.  
  17469.                              Developer Technical Support
  17470.                              Apple Computer, Inc.
  17471.                              20525 Mariani Avenue, M/S 75-3T
  17472.                              Cupertino, CA 95014
  17473.  
  17474.                          for the latest version of the International Utilities
  17475.                          Package, which will be extended to handle non-Roman
  17476.                          alphabets.
  17477.  
  17478. æKY Globals
  17479. æKL ACount
  17480. ANumber
  17481. ApFontID
  17482. ApplScratch
  17483. AppParmHandle
  17484. DABeeper
  17485. DAStrings
  17486. DefVCBPtr
  17487. DlgFont
  17488. DragPattern
  17489. FCBSPtr
  17490. FinderName
  17491. FScaleDisable
  17492. FSQHdr
  17493. MBarEnable
  17494. MBarHook
  17495. MenuFlash
  17496. MenuHook
  17497. MenuList
  17498. OldContent
  17499. OldStructure
  17500. PrintErr
  17501. ROMFont0
  17502. SaveUpdate
  17503. SaveVisRgn
  17504. TheMenu
  17505. ToExtFS
  17506. ToolScratch
  17507. VCBQHdr
  17508. HiKeyLast
  17509. KbdLast
  17510. PCDeskPat
  17511. Time
  17512. ABusDCE
  17513. ABusVars
  17514. ADBBase
  17515. AlarmState
  17516. ApplLimit
  17517. ApplZone
  17518. ASCBase
  17519. BootDrive
  17520. BufPtr
  17521. BufTgDate
  17522. BufTgFBkNum
  17523. BufTgFFlg
  17524. BufTgFNum
  17525. BusErrVct
  17526. CaretTime
  17527. ChunkyDepth
  17528. ColLines
  17529. CPUFlag
  17530. CrsrAddr
  17531. CrsrBase
  17532. CrsrBusy
  17533. CrsrCouple
  17534. CrsrDevice
  17535. CrsrNew
  17536. CrsrObscure
  17537. CrsrPin
  17538. CrsrPtr
  17539. CrsrRect
  17540. CrsrRow
  17541. CrsrSave
  17542. CrsrScale
  17543. CrsrState
  17544. CrsrThresh
  17545. CrsrVis
  17546. CurActivate
  17547. CurApName
  17548. CurApRefNum
  17549. CurDeactive
  17550. CurDirStore
  17551. CurJTOffset
  17552. CurMap
  17553. CurPageOption
  17554. CurPitch
  17555. CurrentA5
  17556. CurStackBase
  17557. DefltStack
  17558. DeskHook
  17559. DeskPattern
  17560. DeviceList
  17561. DoubleTime
  17562. DragHook
  17563. DrvQHdr
  17564. DSAlertRect
  17565. DSAlertTab
  17566. DSCtrAdj
  17567. DSDrawProc
  17568. DSErrCode
  17569. DskErr
  17570. DskVerify
  17571. DSWndUpdate
  17572. DTQFlags
  17573. DTQueue
  17574. DTskQHdr
  17575. DTskQTail
  17576. EjectNotify
  17577. EndSRTPtr
  17578. EventQueue
  17579. EvtBufCnt
  17580. ExpandMem
  17581. ExtStsDT
  17582. GetParam
  17583. GhostWindow
  17584. GrayRgn
  17585. GZMoveHnd
  17586. GZRootHnd
  17587. GZRootPtr
  17588. HeapEnd
  17589. HiHeapMark
  17590. HiliteMode
  17591. HiliteRGB
  17592. HpChk
  17593. IAZNotify
  17594. IconTLAddr
  17595. IntFlag
  17596. IntlSpec
  17597. IWM
  17598. JAllocCrsr
  17599. JCrsrTask
  17600. JDTInstall
  17601. JFetch
  17602. JGNEFilter
  17603. JIODone
  17604. JKybdTask
  17605. JOpcodeProc
  17606. JournalFlag
  17607. JournalRef
  17608. JSetCCrsr
  17609. JStash
  17610. JSwapMMU
  17611. JVBLTask
  17612. KbdType
  17613. KbdVars
  17614. Key1Trans
  17615. Key2Trans
  17616. KeyLast
  17617. KeyMapLM
  17618. KeyMVars
  17619. KeypadMap
  17620. KeyRepThresh
  17621. KeyRepTime
  17622. KeyThresh
  17623. KeyTime
  17624. LastTxGDevice
  17625. LaunchFlag
  17626. Lo3Bytes
  17627. LoaderPBlock
  17628. LoadTrap
  17629. Lvl1DT
  17630. Lvl2DT
  17631. MainDevice
  17632. MaskBC
  17633. MaskHandle
  17634. MaskPtr
  17635. MBarHeight
  17636. MBState
  17637. MBTicks
  17638. MemErr
  17639. MemTop
  17640. MickeyBytes
  17641. MinStack
  17642. MinusOne
  17643. MMDefFlags
  17644. MmInOK
  17645. MMU32bit
  17646. MMUFlags
  17647. MMUFluff
  17648. MMUTbl
  17649. MMUTblSize
  17650. MMUType
  17651. MonkeyLives
  17652. Mouse
  17653. MouseMask
  17654. MouseOffset
  17655. MTemp
  17656. NewCrsrJTbl
  17657. NMIFlag
  17658. OneOne
  17659. PaintWhite
  17660. PortAUse
  17661. PortBUse
  17662. PortList
  17663. PWMBuf2
  17664. QDColors
  17665. QDErrLM
  17666. QDExist
  17667. RAMBase
  17668. RawMouse
  17669. ResErr
  17670. ResErrProc
  17671. ResLoad
  17672. ResReadOnly
  17673. RestProc
  17674. ResumeProc
  17675. RGBBlack
  17676. RGBWhite
  17677. RndSeed
  17678. ROM85
  17679. ROMBase
  17680. ROMMapHndl
  17681. RomMapInsert
  17682. RowBits
  17683. SaveSegHandle
  17684. SCCASts
  17685. SCCBSts
  17686. SCCRd
  17687. SCCWr
  17688. ScrapCount
  17689. ScrapEnd
  17690. ScrapHandle
  17691. ScrapInfo
  17692. ScrapName
  17693. ScrapSize
  17694. ScrapState
  17695. ScrapTag
  17696. ScrapVars
  17697. Scratch20
  17698. Scratch8
  17699. ScrDmpEnb
  17700. ScrDmpType
  17701. ScreenBytes
  17702. ScreenRow
  17703. ScrHRes
  17704. ScrnBase
  17705. ScrnVBLPtr
  17706. ScrVRes
  17707. SCSIBase
  17708. SCSIDMA
  17709. SCSIGlobals
  17710. SCSIHsk
  17711. SCSIPoll
  17712. SdmBusErr
  17713. SDMJmpTblPtr
  17714. SdVolume
  17715. SegHiEnable
  17716. SerialVars
  17717. SEVarBase
  17718. SEvtEnb
  17719. SFSaveDisk
  17720. SInfoPtr
  17721. SInitFlags
  17722. SlotPrTbl
  17723. SlotQDT
  17724. SlotTICKS
  17725. SlotVBLQ
  17726. SoundActive
  17727. SoundBase
  17728. SoundDCE
  17729. SoundLevel
  17730. SoundPtr
  17731. SoundVBL
  17732. SPAlarm
  17733. SPATalkA
  17734. SPATalkB
  17735. SPClikCaret
  17736. SPConfig
  17737. SPFont
  17738. SPKbd
  17739. SPMisc1
  17740. SPMisc2
  17741. SPPortA
  17742. SPPortB
  17743. SPPrint
  17744. SPValid
  17745. SPVolCtl
  17746. SrcDevice
  17747. SRsrcTblPtr
  17748. StkLowPt
  17749. SwitcherTPtr
  17750. SysEvtBuf
  17751. SysEvtMask
  17752. SysMap
  17753. SysMapHndl
  17754. SysParam
  17755. SysResName
  17756. SysVersion
  17757. SysZone
  17758. TableSeed
  17759. TagData
  17760. TEDoText
  17761. TERecal
  17762. TEScrpHandle
  17763. TEScrpLength
  17764. TESysJust
  17765. TEWdBreak
  17766. TheCrsr
  17767. TheGDevice
  17768. TheZone
  17769. Ticks
  17770. TimeDBRA
  17771. TimeLM
  17772. TimeSCCDB
  17773. TimeSCSIDB
  17774. TmpResLoad
  17775. TopMapHndl
  17776. UnitNtryCnt
  17777. UTableBase
  17778. VBLQueue
  17779. VertRRate
  17780. VIA
  17781. VIA2DT
  17782. VideoInfoOK
  17783. VidMode
  17784. VidType
  17785. WarmStart
  17786. WindowList
  17787. WMgrCPort
  17788. WMgrPort
  17789. WordRedraw
  17790. WWExist
  17791.  
  17792. æKY ACount
  17793. æFp Globals
  17794. æC ACount  = $A9A [GLOBAL VAR] Stage number (0 through 3) of last alert (word)
  17795.  
  17796. æKY ANumber
  17797. æFp Globals
  17798. æC ANumber  = $A98 [GLOBAL VAR] Resource ID of last alert (word)
  17799.  
  17800. æKY ApFontID
  17801. æFp Globals
  17802. æC ApFontID = $984 [GLOBAL VAR] Font number of application font (word)
  17803.  
  17804. æKY ApplScratch
  17805. æFp Globals
  17806. æC ApplScratch = $A78 [GLOBAL VAR] 12-byte scratch area reserved for use by applications
  17807.  
  17808. æKY AppParmHandle
  17809. æFp Globals
  17810. æC AppParmHandle = $AEC [GLOBAL VAR] Handle to Finder information
  17811.  
  17812. æKY DABeeper
  17813. æFp Globals
  17814. æC DABeeper = $A9C [GLOBAL VAR] Address of current sound procedure
  17815.  
  17816. æKY DAStrings
  17817. æFp Globals
  17818. æC DAStrings = $AA0 [GLOBAL VAR] Handles to ParamText strings (16 bytes) 
  17819.  
  17820. æKY DefVCBPtr
  17821. æFp Globals
  17822. æC DefVCBPtr = $352 [GLOBAL VAR] Pointer to default volume control block 
  17823.  
  17824. æKY DlgFont
  17825. æFp Globals
  17826. æC DlgFont  = $AFA [GLOBAL VAR] Font number for dialogs and alerts (word)
  17827.  
  17828. æKY DragPattern
  17829. æFp Globals
  17830. æC DragPattern = $A34 [GLOBAL VAR] Pattern of dragged region's outline (8 bytes)
  17831.  
  17832. æKY FCBSPtr
  17833. æFp Globals
  17834. æC FCBSPtr = $34E [GLOBAL VAR] Pointer to file-control-block buffer
  17835.  
  17836. æKY FinderName
  17837. æFp Globals
  17838. æC FinderName = $2E0 [GLOBAL VAR] Name of the Finder (length byte followed by up to 15 
  17839. characters)
  17840.  
  17841. æKY FScaleDisable
  17842. æFp Globals
  17843. æC FScaleDisable = $A63 [GLOBAL VAR] Nonzero to disable font scaling (byte)
  17844.  
  17845. æKY FSQHdr
  17846. æFp Globals
  17847. æC FSQHdr = $360 [GLOBAL VAR] File I/O queue header (10 bytes)
  17848.  
  17849. æKY MBarEnable
  17850. æFp Globals
  17851. æC MBarEnable = $A20 [GLOBAL VAR] Unique menu ID for active desk accessory, when menu bar 
  17852.                   belongs to the accessory (word) 
  17853.  
  17854. æKY MBarHook
  17855. æFp Globals
  17856. æC MBarHook = $A2C [GLOBAL VAR] Address of routine called by MenuSelect before menu is 
  17857.                 drawn
  17858.  
  17859. æKY MenuFlash
  17860. æFp Globals
  17861. æC MenuFlash = $A24 [GLOBAL VAR] Count for duration of menu item blinking (word)
  17862.  
  17863. æKY MenuHook
  17864. æFp Globals
  17865. æC MenuHook = $A30 [GLOBAL VAR] Address of routine called during MenuSelect
  17866.  
  17867. æKY MenuList
  17868. æFp Globals
  17869. æC MenuList = $A1C [GLOBAL VAR] Handle to current menu list
  17870.  
  17871. æKY OldContent
  17872. æFp Globals
  17873. æC OldContent = $9EA [GLOBAL VAR] Handle to saved content region
  17874.  
  17875. æKY OldStructure
  17876. æFp Globals
  17877. æC OldStructure = $9E6 [GLOBAL VAR] Handle to saved structure region
  17878.  
  17879. æKY PrintErr
  17880. æFp Globals
  17881. æC PrintErr = $944 [GLOBAL VAR] Result code from last Printing Manager routine (word)
  17882.  
  17883. æKY ROMFont0
  17884. æFp Globals
  17885. æC ROMFont0 = $980 [GLOBAL VAR] Handle to font record for system font
  17886.  
  17887. æKY SaveUpdate
  17888. æFp Globals
  17889. æC SaveUpdate = $9DA [GLOBAL VAR] Flag for whether to generate update events (word)
  17890.  
  17891. æKY SaveVisRgn
  17892. æFp Globals
  17893. æC SaveVisRgn = $9F2 [GLOBAL VAR] Handle to saved visRgn
  17894.  
  17895. æKY TheMenu
  17896. æFp Globals
  17897. æC TheMenu  = $A26 [GLOBAL VAR] Menu ID of currently highlighted menu (word)
  17898.  
  17899. æKY ToExtFS
  17900. æFp Globals
  17901. æC ToExtFS  = $3F2 [GLOBAL VAR] Pointer to external file system
  17902.  
  17903. æKY ToolScratch
  17904. æFp Globals
  17905. æC ToolScratch = $9CE [GLOBAL VAR] 8-byte scratch area
  17906.  
  17907. æKY VCBQHdr
  17908. æFp Globals
  17909. æC VCBQHdr  = $356 [GLOBAL VAR] Volume-control-block queue header (10 bytes)
  17910.  
  17911.  
  17912. æKY Graf3D.p
  17913. æKL Clip3D
  17914. GetPort3D
  17915. Identity
  17916. InitGrf3d
  17917. Line2D
  17918. Line3D
  17919. LineTo2D
  17920. LineTo3D
  17921. LookAt
  17922. Move2D
  17923. Move3D
  17924. MoveTo2D
  17925. MoveTo3D
  17926. Open3DPort
  17927. Pitch
  17928. Roll
  17929. Scale
  17930. SetPort3D
  17931. SetPt2D
  17932. SetPt3D
  17933. Skew
  17934. Transform
  17935. Translate
  17936. ViewAngle
  17937. ViewPort
  17938. Yaw
  17939.  
  17940. radConst
  17941. XfMatrix
  17942.  
  17943. æKY Port3D
  17944. æFp Graf3D.p
  17945. æT RECORD
  17946. æC Port3D = RECORD
  17947.    grPort: GrafPtr;
  17948.    viewRect: Rect;
  17949.    xLeft: Fixed;
  17950.    yTop: Fixed;
  17951.    xRight: Fixed;
  17952.    yBottom: Fixed;
  17953.    pen: Point3D;
  17954.    penPrime: Point3D;
  17955.    eye: Point3D;
  17956.    hSize: Fixed;
  17957.    vSize: Fixed;
  17958.    hCenter: Fixed;
  17959.    vCenter: Fixed;
  17960.    xCotan: Fixed;
  17961.    yCotan: Fixed;
  17962.    ident: BOOLEAN;
  17963.    xForm: XfMatrix;
  17964.    END;
  17965.  
  17966. æKY Port3DPtr
  17967. æFp Graf3D.p
  17968. æT TYPE
  17969. æC Port3DPtr = ^Port3D;
  17970. Port3D = RECORD
  17971.    grPort: GrafPtr;
  17972.    viewRect: Rect;
  17973.    xLeft: Fixed;
  17974.    yTop: Fixed;
  17975.    xRight: Fixed;
  17976.    yBottom: Fixed;
  17977.    pen: Point3D;
  17978.    penPrime: Point3D;
  17979.    eye: Point3D;
  17980.    hSize: Fixed;
  17981.    vSize: Fixed;
  17982.    hCenter: Fixed;
  17983.    vCenter: Fixed;
  17984.    xCotan: Fixed;
  17985.    yCotan: Fixed;
  17986.    ident: BOOLEAN;
  17987.    xForm: XfMatrix;
  17988.    END;
  17989.  
  17990. æKY Clip3D
  17991. æFp Graf3D.p
  17992. æT FUNCTION
  17993. æD FUNCTION Clip3D(src1: Point3D;src2: Point3D;VAR dst1: Point;VAR dst2: Point): INTEGER;
  17994. æDT myVariable := Clip3D(src1,src2,dst1,dst2);
  17995.  
  17996. æKY GetPort3D
  17997. æFp Graf3D.p
  17998. æT PROCEDURE
  17999. æD PROCEDURE GetPort3D(VAR port: Port3DPtr);
  18000. æDT GetPort3D(port);
  18001. æC     GetPort returns a pointer to the current grafPort. If you have a
  18002. program that draws into more than one grafPort, it's extremely useful 
  18003. to have each procedure save the current grafPort (with GetPort), set
  18004. its own grafPort, do drawing or calculations, and then restore the
  18005. previous grafPort (with SetPort). The pointer to the current grafPort
  18006. is also available through the global pointer thePort, but you may
  18007. prefer to use GetPort for better readability of your program text. For
  18008. example, a procedure could do a GetPort (savePort) before setting its
  18009. own grafPort and a SetPort (savePort) afterwards to restore the
  18010. previous port.
  18011.  
  18012. æKY Identity
  18013. æFp Graf3D.p
  18014. æT PROCEDURE
  18015. æD PROCEDURE Identity;
  18016. æDT Identity;
  18017.  
  18018. æKY InitGrf3d
  18019. æFp Graf3D.p
  18020. æT PROCEDURE
  18021. æD PROCEDURE InitGrf3d(port: Port3DPtr);
  18022. æDT InitGrf3d(port);
  18023.  
  18024. æKY Line2D
  18025. æFp Graf3D.p
  18026. æT PROCEDURE
  18027. æD PROCEDURE Line2D(dx: Fixed;dy: Fixed);
  18028. æDT Line2D(dx,dy);
  18029.  
  18030. æKY Line3D
  18031. æFp Graf3D.p
  18032. æT PROCEDURE
  18033. æD PROCEDURE Line3D(dx: Fixed;dy: Fixed;dz: Fixed);
  18034. æDT Line3D(dx,dy,dz);
  18035.  
  18036. æKY LineTo2D
  18037. æFp Graf3D.p
  18038. æT PROCEDURE
  18039. æD PROCEDURE LineTo2D(x: Fixed;y: Fixed);
  18040. æDT LineTo2D(x,y);
  18041. æC     This procedure draws a line to the location that is a distance of dh
  18042. horizontally and dv vertically from the current pen location; it calls
  18043. LineTo(h+dh,v+dv), where (h,v) is the current location. The positive
  18044. directions are to the right and down. The pen location becomes the
  18045. coordinates of the end of the line after the line is drawn. See the
  18046. general discussion of drawing.
  18047.  
  18048.     If a region or polygon is open and being formed, its outline is
  18049. infinitely thin and is not affected by the pnSize, pnMode, or pnPat.
  18050. (See OpenRgn and OpenPoly.)
  18051.  
  18052. æKY LineTo3D
  18053. æFp Graf3D.p
  18054. æT PROCEDURE
  18055. æD PROCEDURE LineTo3D(x: Fixed;y: Fixed;z: Fixed);
  18056. æDT LineTo3D(x,y,z);
  18057.  
  18058. æKY LookAt
  18059. æFp Graf3D.p
  18060. æT PROCEDURE
  18061. æD PROCEDURE LookAt(left: Fixed;top: Fixed;right: Fixed;bottom: Fixed);
  18062. æDT LookAt(left,top,right,bottom);
  18063.  
  18064. æKY Move2D
  18065. æFp Graf3D.p
  18066. æT PROCEDURE
  18067. æD PROCEDURE Move2D(dx: Fixed;dy: Fixed);
  18068. æDT Move2D(dx,dy);
  18069.  
  18070. æKY Move3D
  18071. æFp Graf3D.p
  18072. æT PROCEDURE
  18073. æD PROCEDURE Move3D(dx: Fixed;dy: Fixed;dz: Fixed);
  18074. æDT Move3D(dx,dy,dz);
  18075.  
  18076. æKY MoveTo2D
  18077. æFp Graf3D.p
  18078. æT PROCEDURE
  18079. æD PROCEDURE MoveTo2D(x: Fixed;y: Fixed);
  18080. æDT MoveTo2D(x,y);
  18081. æC     MoveTo moves the pen to location  (h,v) in the local coordinates of
  18082. the current grafPort. No drawing is performed.
  18083.  
  18084. æKY MoveTo3D
  18085. æFp Graf3D.p
  18086. æT PROCEDURE
  18087. æD PROCEDURE MoveTo3D(x: Fixed;y: Fixed;z: Fixed);
  18088. æDT MoveTo3D(x,y,z);
  18089.  
  18090. æKY Open3DPort
  18091. æFp Graf3D.p
  18092. æT PROCEDURE
  18093. æD PROCEDURE Open3DPort(port: Port3DPtr);
  18094. æDT Open3DPort(port);
  18095.  
  18096. æKY Pitch
  18097. æFp Graf3D.p
  18098. æT PROCEDURE
  18099. æD PROCEDURE Pitch(xAngle: Fixed);
  18100. æDT Pitch(xAngle);
  18101.  
  18102. æKY Point2D
  18103. æFp Graf3D.p
  18104. æT RECORD
  18105. æC Point2D = RECORD
  18106.    x: Fixed;
  18107.    y: Fixed;
  18108.    END;
  18109.  
  18110. æKY Point3D
  18111. æFp Graf3D.p
  18112. æT RECORD
  18113. æC Point3D = RECORD
  18114.    x: Fixed;
  18115.    y: Fixed;
  18116.    z: Fixed;
  18117.    END;
  18118.  
  18119. æKY radConst
  18120. æFp Graf3D.p
  18121. æC radConst = 3754936;
  18122.  
  18123. æKY Roll
  18124. æFp Graf3D.p
  18125. æT PROCEDURE
  18126. æD PROCEDURE Roll(zAngle: Fixed);
  18127. æDT Roll(zAngle);
  18128.  
  18129. æKY Scale
  18130. æFp Graf3D.p
  18131. æT PROCEDURE
  18132. æD PROCEDURE Scale(xFactor: Fixed;yFactor: Fixed;zFactor: Fixed);
  18133. æDT Scale(xFactor,yFactor,zFactor);
  18134.  
  18135. æKY SetPort3D
  18136. æFp Graf3D.p
  18137. æT PROCEDURE
  18138. æD PROCEDURE SetPort3D(port: Port3DPtr);
  18139. æDT SetPort3D(port);
  18140. æC     SetPort sets the grafPort indicated by gp to be the current port.
  18141. The global pointer thePort always points to the current port. All
  18142. QuickDraw drawing routines affect the bitMap thePort^.portBits and use
  18143. the local coordinate system of thePort^. Note that OpenPort and
  18144. InitPort do a SetPort to the given port.
  18145.  
  18146. Warning:
  18147.  
  18148.     Never do a SetPort to a port that has not been opened
  18149.     with OpenPort.
  18150.  
  18151.     Each port possesses its own pen and text characteristics which
  18152. remain unchanged when the port is not selected as the current port.
  18153.  
  18154. æKY SetPt2D
  18155. æFp Graf3D.p
  18156. æT PROCEDURE
  18157. æD PROCEDURE SetPt2D(VAR pt2D: Point2D;x: Fixed;y: Fixed);
  18158. æDT SetPt2D(pt2D,x,y);
  18159.  
  18160. æKY SetPt3D
  18161. æFp Graf3D.p
  18162. æT PROCEDURE
  18163. æD PROCEDURE SetPt3D(VAR pt3D: Point3D;x: Fixed;y: Fixed;z: Fixed);
  18164. æDT SetPt3D(pt3D,x,y,z);
  18165. æC     SetPt assigns two integer coordinates to a variable of type Point.
  18166.  
  18167.  
  18168. æKY Skew
  18169. æFp Graf3D.p
  18170. æT PROCEDURE
  18171. æD PROCEDURE Skew(zAngle: Fixed);
  18172. æDT Skew(zAngle);
  18173.  
  18174. æKY Transform
  18175. æFp Graf3D.p
  18176. æT PROCEDURE
  18177. æD PROCEDURE Transform(src: Point3D;VAR dst: Point3D);
  18178. æDT Transform(src,dst);
  18179.  
  18180. æKY Translate
  18181. æFp Graf3D.p
  18182. æT PROCEDURE
  18183. æD PROCEDURE Translate(dx: Fixed;dy: Fixed;dz: Fixed);
  18184. æDT Translate(dx,dy,dz);
  18185.  
  18186. æKY ViewAngle
  18187. æFp Graf3D.p
  18188. æT PROCEDURE
  18189. æD PROCEDURE ViewAngle(angle: Fixed);
  18190. æDT ViewAngle(angle);
  18191.  
  18192. æKY ViewPort
  18193. æFp Graf3D.p
  18194. æT PROCEDURE
  18195. æD PROCEDURE ViewPort(r: Rect);
  18196. æDT ViewPort(r);
  18197.  
  18198. æKY XfMatrix
  18199. æFp Graf3D.p
  18200. æT TYPE
  18201. æC XfMatrix = ARRAY [0..3, 0..3] OF Fixed;
  18202.  
  18203. æKY Yaw
  18204. æFp Graf3D.p
  18205. æT PROCEDURE
  18206. æD PROCEDURE Yaw(yAngle: Fixed);
  18207. æDT Yaw(yAngle);
  18208.  
  18209.  
  18210. æKY HyperXCmd.p
  18211. æKL BoolToStr
  18212. EvalExpr
  18213. ExtToStr
  18214. GetFieldByID
  18215. GetFieldByName
  18216. GetFieldByNum
  18217. GetGlobal
  18218. LongToStr
  18219. NumToHex
  18220. NumToStr
  18221. PasToZero
  18222. ReturnToPas
  18223. ScanToReturn
  18224. ScanToZero
  18225. SendCardMessage
  18226. SendHCMessage
  18227. SetFieldByID
  18228. SetFieldByName
  18229. SetFieldByNum
  18230. SetGlobal
  18231. StringEqual
  18232. StringLength
  18233. StringMatch
  18234. StrToBool
  18235. StrToExt
  18236. StrToLong
  18237. StrToNum
  18238. ZeroBytes
  18239. ZeroToPas
  18240.  
  18241. XCmdBlock
  18242. XCmdPtr
  18243. xreqBoolToStr
  18244. xreqEvalExpr
  18245. xreqExtToStr
  18246. xreqGetFieldByID
  18247. xreqGetFieldByName
  18248. xreqGetFieldByNum
  18249. xreqGetGlobal
  18250. xreqLongToStr
  18251. xreqNumToHex
  18252. xreqNumToStr
  18253. xreqPasToZero
  18254. xreqReturnToPas
  18255. xreqScanToReturn
  18256. xreqScanToZero
  18257. xreqSendCardMessage
  18258. xreqSendHCMessage
  18259. xreqSetFieldByID
  18260. xreqSetFieldByName
  18261. xreqSetFieldByNum
  18262. xreqSetGlobal
  18263. xreqStringEqual
  18264. xreqStringLength
  18265. xreqStringMatch
  18266. xreqStrToBool
  18267. xreqStrToExt
  18268. xreqStrToLong
  18269. xreqStrToNum
  18270. xreqZeroBytes
  18271. xreqZeroToPas
  18272. xresFail
  18273. xresNotImp
  18274. xresSucc
  18275.  
  18276. æKY XCmdBlock
  18277. æFp HyperXCmd.p
  18278. æT RECORD
  18279. æC XCmdBlock = RECORD
  18280.    paramCount: INTEGER;
  18281.    params: ARRAY [1..16] OF Handle;
  18282.    returnValue: Handle;
  18283.    passFlag: BOOLEAN;
  18284.    entryPoint: ProcPtr;    {to call back to HyperCard}
  18285.    request: INTEGER;
  18286.    result: INTEGER;
  18287.    inArgs: ARRAY [1..8] OF LONGINT;
  18288.    outArgs: ARRAY [1..4] OF LONGINT;
  18289.    END;
  18290.  
  18291. æKY XCmdPtr
  18292. æFp HyperXCmd.p
  18293. æT TYPE
  18294. æC XCmdPtr = ^XCmdBlock;
  18295. XCmdBlock = RECORD
  18296.    paramCount: INTEGER;
  18297.    params: ARRAY [1..16] OF Handle;
  18298.    returnValue: Handle;
  18299.    passFlag: BOOLEAN;
  18300.    entryPoint: ProcPtr;    {to call back to HyperCard}
  18301.    request: INTEGER;
  18302.    result: INTEGER;
  18303.    inArgs: ARRAY [1..8] OF LONGINT;
  18304.    outArgs: ARRAY [1..4] OF LONGINT;
  18305.    END;
  18306.  
  18307. æKY BoolToStr
  18308. æFp HyperXCmd.p
  18309. æT PROCEDURE
  18310. æD PROCEDURE BoolToStr(paramPtr: XCmdPtr;bool: BOOLEAN;VAR str: Str255);
  18311. æDT BoolToStr(paramPtr,bool,str);
  18312.  
  18313. æKY EvalExpr
  18314. æFp HyperXCmd.p
  18315. æT FUNCTION
  18316. æD FUNCTION EvalExpr(paramPtr: XCmdPtr;expr: Str255): Handle;
  18317. æDT myVariable := EvalExpr(paramPtr,expr);
  18318.  
  18319. æKY ExtToStr
  18320. æFp HyperXCmd.p
  18321. æT PROCEDURE
  18322. æD PROCEDURE ExtToStr(paramPtr: XCmdPtr;num: Extended;VAR str: Str255);
  18323. æDT ExtToStr(paramPtr,num,str);
  18324.  
  18325. æKY GetFieldByID
  18326. æFp HyperXCmd.p
  18327. æT FUNCTION
  18328. æD FUNCTION GetFieldByID(paramPtr: XCmdPtr;cardFieldFlag: BOOLEAN;fieldID: INTEGER): Handle;
  18329. æDT myVariable := GetFieldByID(paramPtr,cardFieldFlag,fieldID);
  18330.  
  18331. æKY GetFieldByName
  18332. æFp HyperXCmd.p
  18333. æT FUNCTION
  18334. æD FUNCTION GetFieldByName(paramPtr: XCmdPtr;cardFieldFlag: BOOLEAN;fieldName: Str255): Handle;
  18335. æDT myVariable := GetFieldByName(paramPtr,cardFieldFlag,fieldName);
  18336.  
  18337. æKY GetFieldByNum
  18338. æFp HyperXCmd.p
  18339. æT FUNCTION
  18340. æD FUNCTION GetFieldByNum(paramPtr: XCmdPtr;cardFieldFlag: BOOLEAN;fieldNum: INTEGER): Handle;
  18341. æDT myVariable := GetFieldByNum(paramPtr,cardFieldFlag,fieldNum);
  18342.  
  18343. æKY GetGlobal
  18344. æFp HyperXCmd.p
  18345. æT FUNCTION
  18346. æD FUNCTION GetGlobal(paramPtr: XCmdPtr;globName: Str255): Handle;
  18347. æDT myVariable := GetGlobal(paramPtr,globName);
  18348.  
  18349. æKY LongToStr
  18350. æFp HyperXCmd.p
  18351. æT PROCEDURE
  18352. æD PROCEDURE LongToStr(paramPtr: XCmdPtr;posNum: LONGINT;VAR str: Str255);
  18353. æDT LongToStr(paramPtr,posNum,str);
  18354.  
  18355. æKY NumToHex
  18356. æFp HyperXCmd.p
  18357. æT PROCEDURE
  18358. æD PROCEDURE NumToHex(paramPtr: XCmdPtr;num: LONGINT;nDigits: INTEGER;VAR str: Str255);
  18359. æDT NumToHex(paramPtr,num,nDigits,str);
  18360.  
  18361. æKY NumToStr
  18362. æFp HyperXCmd.p
  18363. æT PROCEDURE
  18364. æD PROCEDURE NumToStr(paramPtr: XCmdPtr;num: LONGINT;VAR str: Str255);
  18365. æDT NumToStr(paramPtr,num,str);
  18366.  
  18367. æKY PasToZero
  18368. æFp HyperXCmd.p
  18369. æT FUNCTION
  18370. æD FUNCTION PasToZero(paramPtr: XCmdPtr;str: Str255): Handle;
  18371. æDT myVariable := PasToZero(paramPtr,str);
  18372.  
  18373. æKY ReturnToPas
  18374. æFp HyperXCmd.p
  18375. æT PROCEDURE
  18376. æD PROCEDURE ReturnToPas(paramPtr: XCmdPtr;zeroStr: UNIV Ptr;VAR pasStr: Str255);
  18377. æDT ReturnToPas(paramPtr,zeroStr,pasStr);
  18378.  
  18379. æKY ScanToReturn
  18380. æFp HyperXCmd.p
  18381. æT PROCEDURE
  18382. æD PROCEDURE ScanToReturn(paramPtr: XCmdPtr;VAR scanPtr: Ptr);
  18383. æDT ScanToReturn(paramPtr,scanPtr);
  18384.  
  18385. æKY ScanToZero
  18386. æFp HyperXCmd.p
  18387. æT PROCEDURE
  18388. æD PROCEDURE ScanToZero(paramPtr: XCmdPtr;VAR scanPtr: Ptr);
  18389. æDT ScanToZero(paramPtr,scanPtr);
  18390.  
  18391. æKY SendCardMessage
  18392. æFp HyperXCmd.p
  18393. æT PROCEDURE
  18394. æD PROCEDURE SendCardMessage(paramPtr: XCmdPtr;msg: Str255);
  18395. æDT SendCardMessage(paramPtr,msg);
  18396.  
  18397. æKY SendHCMessage
  18398. æFp HyperXCmd.p
  18399. æT PROCEDURE
  18400. æD PROCEDURE SendHCMessage(paramPtr: XCmdPtr;msg: Str255);
  18401. æDT SendHCMessage(paramPtr,msg);
  18402.  
  18403. æKY SetFieldByID
  18404. æFp HyperXCmd.p
  18405. æT PROCEDURE
  18406. æD PROCEDURE SetFieldByID(paramPtr: XCmdPtr;cardFieldFlag: BOOLEAN;fieldID: INTEGER;
  18407.     fieldVal: Handle);
  18408. æDT SetFieldByID(paramPtr,cardFieldFlag,fieldID,fieldVal);
  18409.  
  18410. æKY SetFieldByName
  18411. æFp HyperXCmd.p
  18412. æT PROCEDURE
  18413. æD PROCEDURE SetFieldByName(paramPtr: XCmdPtr;cardFieldFlag: BOOLEAN;fieldName: Str255;
  18414.     fieldVal: Handle);
  18415. æDT SetFieldByName(paramPtr,cardFieldFlag,fieldName,fieldVal);
  18416.  
  18417. æKY SetFieldByNum
  18418. æFp HyperXCmd.p
  18419. æT PROCEDURE
  18420. æD PROCEDURE SetFieldByNum(paramPtr: XCmdPtr;cardFieldFlag: BOOLEAN;fieldNum: INTEGER;
  18421.     fieldVal: Handle);
  18422. æDT SetFieldByNum(paramPtr,cardFieldFlag,fieldNum,fieldVal);
  18423.  
  18424. æKY SetGlobal
  18425. æFp HyperXCmd.p
  18426. æT PROCEDURE
  18427. æD PROCEDURE SetGlobal(paramPtr: XCmdPtr;globName: Str255;globValue: Handle);
  18428. æDT SetGlobal(paramPtr,globName,globValue);
  18429.  
  18430. æKY StringEqual
  18431. æFp HyperXCmd.p
  18432. æT FUNCTION
  18433. æD FUNCTION StringEqual(paramPtr: XCmdPtr;str1: Str255;str2: Str255): BOOLEAN;
  18434. æDT myVariable := StringEqual(paramPtr,str1,str2);
  18435.  
  18436. æKY StringLength
  18437. æFp HyperXCmd.p
  18438. æT FUNCTION
  18439. æD FUNCTION StringLength(paramPtr: XCmdPtr;strPtr: UNIV Ptr): LONGINT;
  18440. æDT myVariable := StringLength(paramPtr,strPtr);
  18441.  
  18442. æKY StringMatch
  18443. æFp HyperXCmd.p
  18444. æT FUNCTION
  18445. æD FUNCTION StringMatch(paramPtr: XCmdPtr;pattern: Str255;target: Ptr): Ptr;
  18446. æDT myVariable := StringMatch(paramPtr,pattern,target);
  18447.  
  18448. æKY StrToBool
  18449. æFp HyperXCmd.p
  18450. æT FUNCTION
  18451. æD FUNCTION StrToBool(paramPtr: XCmdPtr;str: Str255): BOOLEAN;
  18452. æDT myVariable := StrToBool(paramPtr,str);
  18453.  
  18454. æKY StrToExt
  18455. æFp HyperXCmd.p
  18456. æT FUNCTION
  18457. æD FUNCTION StrToExt(paramPtr: XCmdPtr;str: Str255): Extended;
  18458. æDT myVariable := StrToExt(paramPtr,str);
  18459.  
  18460. æKY StrToLong
  18461. æFp HyperXCmd.p
  18462. æT FUNCTION
  18463. æD FUNCTION StrToLong(paramPtr: XCmdPtr;str: Str255): LONGINT;
  18464. æDT myVariable := StrToLong(paramPtr,str);
  18465.  
  18466. æKY StrToNum
  18467. æFp HyperXCmd.p
  18468. æT FUNCTION
  18469. æD FUNCTION StrToNum(paramPtr: XCmdPtr;str: Str255): LONGINT;
  18470. æDT myVariable := StrToNum(paramPtr,str);
  18471.  
  18472. æKY xreqBoolToStr
  18473. æFp HyperXCmd.p
  18474. æC xreqBoolToStr = 16;
  18475.  
  18476. æKY xreqEvalExpr
  18477. æFp HyperXCmd.p
  18478. æC xreqEvalExpr = 2;
  18479.  
  18480. æKY xreqExtToStr
  18481. æFp HyperXCmd.p
  18482. æC xreqExtToStr = 17;
  18483.  
  18484. æKY xreqGetFieldByID
  18485. æFp HyperXCmd.p
  18486. æC xreqGetFieldByID = 22;
  18487.  
  18488. æKY xreqGetFieldByName
  18489. æFp HyperXCmd.p
  18490. æC xreqGetFieldByName = 20;
  18491.  
  18492. æKY xreqGetFieldByNum
  18493. æFp HyperXCmd.p
  18494. æC xreqGetFieldByNum = 21;
  18495.  
  18496. æKY xreqGetGlobal
  18497. æFp HyperXCmd.p
  18498. æC xreqGetGlobal = 18;
  18499.  
  18500. æKY xreqLongToStr
  18501. æFp HyperXCmd.p
  18502. æC xreqLongToStr = 13;
  18503.  
  18504. æKY xreqNumToHex
  18505. æFp HyperXCmd.p
  18506. æC xreqNumToHex = 15;
  18507.  
  18508. æKY xreqNumToStr
  18509. æFp HyperXCmd.p
  18510. æC xreqNumToStr = 14;
  18511.  
  18512. æKY xreqPasToZero
  18513. æFp HyperXCmd.p
  18514. æC xreqPasToZero = 7;
  18515.  
  18516. æKY xreqReturnToPas
  18517. æFp HyperXCmd.p
  18518. æC xreqReturnToPas = 27;
  18519.  
  18520. æKY xreqScanToReturn
  18521. æFp HyperXCmd.p
  18522. æC xreqScanToReturn = 28;
  18523.  
  18524. æKY xreqScanToZero
  18525. æFp HyperXCmd.p
  18526. æC xreqScanToZero = 39; { Yes, really 39!}
  18527.  
  18528. æKY xreqSendCardMessage
  18529. æFp HyperXCmd.p
  18530. æC xreqSendCardMessage = 1;
  18531.  
  18532. æKY xreqSendHCMessage
  18533. æFp HyperXCmd.p
  18534. æC xreqSendHCMessage = 5;
  18535.  
  18536. æKY xreqSetFieldByID
  18537. æFp HyperXCmd.p
  18538. æC xreqSetFieldByID = 25;
  18539.  
  18540. æKY xreqSetFieldByName
  18541. æFp HyperXCmd.p
  18542. æC xreqSetFieldByName = 23;
  18543.  
  18544. æKY xreqSetFieldByNum
  18545. æFp HyperXCmd.p
  18546. æC xreqSetFieldByNum = 24;
  18547.  
  18548. æKY xreqSetGlobal
  18549. æFp HyperXCmd.p
  18550. æC xreqSetGlobal = 19;
  18551.  
  18552. æKY xreqStringEqual
  18553. æFp HyperXCmd.p
  18554. æC xreqStringEqual = 26;
  18555.  
  18556. æKY xreqStringLength
  18557. æFp HyperXCmd.p
  18558. æC xreqStringLength = 3;
  18559.  
  18560. æKY xreqStringMatch
  18561. æFp HyperXCmd.p
  18562. æC xreqStringMatch = 4;
  18563.  
  18564. æKY xreqStrToBool
  18565. æFp HyperXCmd.p
  18566. æC xreqStrToBool = 11;
  18567.  
  18568. æKY xreqStrToExt
  18569. æFp HyperXCmd.p
  18570. æC xreqStrToExt = 12;
  18571.  
  18572. æKY xreqStrToLong
  18573. æFp HyperXCmd.p
  18574. æC xreqStrToLong = 9;
  18575.  
  18576. æKY xreqStrToNum
  18577. æFp HyperXCmd.p
  18578. æC xreqStrToNum = 10;
  18579.  
  18580. æKY xreqZeroBytes
  18581. æFp HyperXCmd.p
  18582. æC xreqZeroBytes = 6;
  18583.  
  18584. æKY xreqZeroToPas
  18585. æFp HyperXCmd.p
  18586. æC xreqZeroToPas = 8;
  18587.  
  18588. æKY xresFail
  18589. æFp HyperXCmd.p
  18590. æC xresFail = 1;
  18591.  
  18592. æKY xresNotImp
  18593. æFp HyperXCmd.p
  18594. æC xresNotImp = 2;
  18595.  
  18596. æKY xresSucc
  18597. æFp HyperXCmd.p
  18598. æC xresSucc = 0;
  18599.  
  18600. æKY ZeroBytes
  18601. æFp HyperXCmd.p
  18602. æT PROCEDURE
  18603. æD PROCEDURE ZeroBytes(paramPtr: XCmdPtr;dstPtr: Ptr;longCount: LONGINT);
  18604. æDT ZeroBytes(paramPtr,dstPtr,longCount);
  18605.  
  18606. æKY ZeroToPas
  18607. æFp HyperXCmd.p
  18608. æT PROCEDURE
  18609. æD PROCEDURE ZeroToPas(paramPtr: XCmdPtr;zeroStr: UNIV Ptr;VAR pasStr: Str255);
  18610. æDT ZeroToPas(paramPtr,zeroStr,pasStr);
  18611.  
  18612.  
  18613. æKY Lists.p
  18614. æKL LActivate
  18615. LAddColumn
  18616. LAddRow
  18617. LAddToCell
  18618. LAutoScroll
  18619. LCellSize
  18620. LClick
  18621. LClrCell
  18622. LDelColumn
  18623. LDelRow
  18624. LDispose
  18625. LDoDraw
  18626. LDraw
  18627. LFind
  18628. LGetCell
  18629. LGetSelect
  18630. LLastClick
  18631. LNew
  18632. LNextCell
  18633. LRect
  18634. LScroll
  18635. LSearch
  18636. LSetCell
  18637. LSetSelect
  18638. LSize
  18639. LUpdate
  18640.  
  18641. Cell
  18642. DataArray
  18643. DataHandle
  18644. DataPtr
  18645. lCloseMsg
  18646. lDoHAutoscroll
  18647. lDoVAutoscroll
  18648. lDrawMsg
  18649. lExtendDrag
  18650. lHiliteMsg
  18651. lInitMsg
  18652. ListHandle
  18653. ListPtr
  18654. ListRec
  18655. lNoDisjoint
  18656. lNoExtend
  18657. lNoNilHilite
  18658. lNoRect
  18659. lOnlyOne
  18660. lUseSense
  18661. Point
  18662.  
  18663. æKY ListRec,ListPtr,ListHandle
  18664. æFp Lists.p
  18665. æT TYPE
  18666. æC ListPtr = ^ListRec;
  18667. ListHandle = ^ListPtr;
  18668. ListRec = RECORD
  18669.    rView: Rect;
  18670.    port: GrafPtr;
  18671.    indent: Point;
  18672.    cellSize: Point;
  18673.    visible: Rect;
  18674.    vScroll: ControlHandle;
  18675.    hScroll: ControlHandle;
  18676.    selFlags: SignedByte;
  18677.    lActive: BOOLEAN;
  18678.    lReserved: SignedByte;
  18679.    listFlags: SignedByte;
  18680.    clikTime: LONGINT;
  18681.    clikLoc: Point;
  18682.    mouseLoc: Point;
  18683.    lClikLoop: ProcPtr;
  18684.    lastClick: Cell;
  18685.    refCon: LONGINT;
  18686.    listDefProc: Handle;
  18687.    userHandle: Handle;
  18688.    dataBounds: Rect;
  18689.    cells: DataHandle;
  18690.    maxIndex: INTEGER;
  18691.    cellArray: ARRAY [1..1] OF INTEGER;
  18692.    END;
  18693.  
  18694. »The List Record Data Structure
  18695.  
  18696. The exact data structure of a list record is as follows:
  18697.  
  18698. TYPE  Cell       = Point;
  18699.       DataArray  = PACKED ARRAY [0..32000] OF CHAR;
  18700.       DataPtr    = ^DataArray;
  18701.       DataHandle = ^DataPtr;
  18702.       ListRec    = RECORD
  18703.                      rView:        Rect;           {list's display rectangle}
  18704.                      port:         GrafPtr;        {list's grafPort}
  18705.                      indent:       Point;          {indent distance}
  18706.                      cellSize:     Point;          {cell size}
  18707.                      visible:      Rect;           {boundary of visible cells}
  18708.                      vScroll:      ControlHandle;  {vertical scroll bar}
  18709.                      hScroll:      ControlHandle;  {horizontal scroll bar}
  18710.                      selFlags:     SignedByte;     {selection flags}
  18711.                      lActive:      BOOLEAN;        {TRUE if active}
  18712.                      lReserved:    SignedByte;     {reserved}
  18713.                      listFlags:    SignedByte;     {automatic scrolling flags}
  18714.                      clikTime:     LONGINT;        {time of last click}
  18715.                      clikLoc:      Point;          {position of last click}
  18716.                      mouseLoc:     Point;          {current mouse location}
  18717.                      lClikLoop:    Ptr;            {routine for LClick}
  18718.                      lastClick:    Cell;           {last cell clicked}
  18719.                      refCon:       LONGINT;        {list's reference value}
  18720.                      listDefProc:  Handle;         {list definition procedure}
  18721.                      userHandle:   Handle;         {additional storage}
  18722.                      dataBounds:   Rect;           {boundary of cells allocated}
  18723.                      cells:        DataHandle;     {cell data}
  18724.                      maxIndex:     INTEGER;        {used internally}
  18725.                      cellArray:    ARRAY [1..1] OF INTEGER    {offsets to data}
  18726.                    END;
  18727.  
  18728.       ListPtr    = ^ListRec;
  18729.       ListHandle = ^ListPtr;
  18730.  
  18731. RView is the rectangle, given in the local coordinates of the grafPort, in which the
  18732. list is displayed. Room for scroll bars is not included in this rectangle. If the
  18733. list has scroll bars and is to fill the entire window, rView should be 15 points
  18734. smaller in each dimension than the grafPort.
  18735.  
  18736. Port is the grafPort used by the list; it’s set to the port of the window specified
  18737. when the list is created. Indent is the distance in pixels that the list definition
  18738. procedure should indent from the topLeft of the cell when drawing the contents. The
  18739. default value for indent is 0, but it can be set by the list definition procedure.
  18740.  
  18741. CellSize is the size of a cell in pixels. If it’s not specified when the list is
  18742. created, a default cell size is set. CellSize.v is set to the ascent plus descent
  18743. plus leading of the port’s font, and cellSize.h is set to
  18744.  
  18745.   (rView.right – rView.left) DIV (dataBounds.right – dataBounds.left)
  18746.  
  18747. A cell is a box in which a list element is displayed. Cells are identified by their
  18748. column and row numbers. In Figure 1, for instance, the highlighted cell is in column
  18749. 1, row 2.
  18750.  
  18751. Cells are declared as points, using the Point data type simply as a way of specifying
  18752. the column and row number of a cell. Similarly, visible and dataBounds use the Rect
  18753. data type to specify a rectangular set of cells as two diagonally opposite cell
  18754. coordinates (rather than two diagonally opposite points in the local coordinates of a
  18755. grafPort).
  18756.  
  18757. DataBounds is the boundary of the cells currently allocated, specified by row and
  18758. column. The list in Figure 1 (assuming the entire list is visible) has seventeen rows
  18759. and five columns of cells. DataBounds for this list can be represented, using the
  18760. QuickDraw rectangle notation (left,top)(right,bottom), as (0,0)(5,17). Notice that
  18761. the column and row specified for the bottom right of dataBounds are 1 greater in each
  18762. dimension than the column and row number of the bottom right cell. Thus, you can test
  18763. to see if a cell is a valid cell within the boundary of a list using the statement:
  18764.  
  18765.   IF PtInRect(c,myList^^.dataBounds) THEN...
  18766.  
  18767. The visible rectangle reflects which cells are currently within the visible part of
  18768. the list; it’s calculated by the List Manager according to the values you specify for
  18769. rView, dataBounds, and cellSize when you create the list.
  18770. (Visible.topLeft is the row and column of the top left visible cell; visible.botRight
  18771. is 1 greater in both dimensions than the row and column of the bottom right visible
  18772. cell.) For example, if only four cells—row 2, column 0; row 2, column 1; row 3,
  18773. column 0; and row 3, column 1—are visible, the visible rectangle is (0,2)(2,4). You
  18774. can test to see if a cell is visible using the statement:
  18775.  
  18776.   IF PtInRect(c,myList^^.visible) THEN...
  18777.  
  18778. •••Refer to Figure 1.•••
  18779.  
  18780. Figure 1–A Sample List
  18781.  
  18782. SelFlags contains selection flags for the List Manager. It’s initialized to 0; with
  18783. this setting, the List Manager selects cells according to the Macintosh User Interface
  18784. Guidelines. The meaning of these flags is explained below in the section “Cell Selection
  18785. Algorithm”. The listFlags field contains automatic scrolling flags; the List Manager
  18786. sets these flags automatically when you specify scroll bars. There are predefined
  18787. constants that let you set or test the status of the corresponding bits:
  18788.  
  18789. CONST  lDoVAutoScroll = 2;    {set to allow automatic vertical scrolling}
  18790.        lDoHAutoScroll = 1;    {set to allow automatic horizontal scrolling}
  18791.  
  18792. ClikLoc is the position of the last mouse click in local coordinates; you can use it
  18793. in the list definition procedure to get the position within the cell. LClikLoop is a
  18794. pointer to the routine to be called during the LClick function, as described later.
  18795. LastClick contains the cell coordinates of the last cell clicked in.
  18796.  
  18797. RefCon is the list’s reference value field, which the application may store into and
  18798. access for any purpose. In addition, the application may use the field userHandle to
  18799. store a handle to an additional storage area.
  18800.  
  18801. CellArray contains offsets to the cell data. For each list element, this includes the
  18802. bit indicating whether the cell is selected or not.
  18803.  
  18804. »The LClikLoop Field
  18805.  
  18806. The lClikLoop field of a list record lets you specify a routine that will be called
  18807. repeatedly (by the LClick function, described below) as long as the mouse button is
  18808. held down within the rView rectangle or its scroll bars.
  18809.  
  18810. Note:  The LClick function performs automatic scrolling if the mouse is
  18811.        dragged outside the visible rectangle, so there’s no need to write
  18812.        a list click loop routine to do automatic scrolling.
  18813.  
  18814. The list click loop routine has no parameters and returns a Boolean value. You could
  18815. declare a list click loop routine named MyClikLoop like this:
  18816.  
  18817. FUNCTION MyClikLoop :  BOOLEAN;
  18818.  
  18819. The function should return TRUE. You must put a pointer to your list click loop
  18820. routine in the lClikLoop field of the list record so that the List Manager will call
  18821. your routine.
  18822.  
  18823. Warning:  Returning FALSE from your list click loop routine tells the
  18824.           LClick function that the mouse button has been released, which
  18825.           aborts LClick.
  18826.  
  18827. Assembly-language note:  Your routine should set register D0 to 1; returning
  18828.                          0 in register D0 aborts LClick. For your convenience,
  18829.                          register D5 contains the current mouse location.
  18830.  
  18831. æKY Cell,Point
  18832. æFp Lists.p
  18833. æT TYPE
  18834. æC Cell = Point;
  18835. Point = RECORD
  18836.    CASE INTEGER OF
  18837.      1:
  18838.        (v: INTEGER;        {vertical coordinate}
  18839.        h: INTEGER);        {horizontal coordinate}
  18840.      2:
  18841.        (vh: ARRAY[VHSelect] OF INTEGER);
  18842.    END;
  18843.  
  18844. æKY DataHandle,DataPtr,DataArray
  18845. æFp Lists.p
  18846. æT TYPE
  18847. æC DataPtr = ^DataArray;
  18848. DataHandle = ^DataPtr;
  18849. DataArray = PACKED ARRAY [0..32000] OF CHAR;
  18850.  
  18851. æKY LActivate
  18852. æFp Lists.p
  18853. æT PROCEDURE
  18854. æTN $A9E7
  18855. æD PROCEDURE LActivate(act: BOOLEAN;lHandle: ListHandle);
  18856. æDT LActivate(act,lHandle);
  18857. æRI LActivate procedure  IV-276 
  18858. æC 
  18859. Call LActivate to activate or deactivate the list specified by lHandle (in response
  18860. to an activate event in the window containing the list). The act parameter should be
  18861. set to TRUE to activate the list, or FALSE to deactivate the list. LActivate highlights
  18862. or unhighlights the selections, and shows or hides the scroll bars (but not the size
  18863. box, if any).
  18864.  
  18865. Assembly-language note:  You can invoke each of the List Manager routines
  18866.                          with a macro that has the same name as the routine
  18867.                          preceded by an underscore. These macros expand to
  18868.                          invoke to trap macro _Pack 0. The package determines
  18869.                          which routine to execute from a routine selector, an
  18870.                          integer that’s passed to it in a word on the stack.
  18871.                          The routine selectors are as follows:
  18872.  
  18873.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  18874.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  18875.                            lAddRow     .EQU    8    lClick       .EQU    24
  18876.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  18877.                            lDelColumn  .EQU    32   lNew         .EQU    68
  18878.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  18879.                            lDispose    .EQU    40   lRect        .EQU    76
  18880.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  18881.                            lDraw       .EQU    48   lSearch      .EQU    84
  18882.                            lFind       .EQU    52   lSetCell     .EQU    88
  18883.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  18884.                            lGetSelect  .EQU    60   lSize        .EQU    96
  18885.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  18886.  
  18887. æKY LAddColumn
  18888. æFp Lists.p
  18889. æT FUNCTION
  18890. æTN $A9E7
  18891. æD FUNCTION LAddColumn(count: INTEGER;colNum: INTEGER;lHandle: ListHandle): INTEGER;
  18892. æDT myVariable := LAddColumn(count,colNum,lHandle);
  18893. æRI LAddColumn function  IV-271
  18894. æC 
  18895. LAddColumn inserts into the given list the number of columns specified by the count
  18896. parameter, starting at the column specified by colNum. Column numbers that are greater
  18897. than or equal to colNum are increased by count. If colNum is not within dataBounds,
  18898. new last columns are added. The number of the first added column is returned and
  18899. dataBounds.right is increased by count. All cells added are empty. If there are no
  18900. cells (because dataBounds.top = dataBounds.bottom), no cells are added, but dataBounds
  18901. is still extended. If drawing is on and the added columns (which are empty) are
  18902. visible, the list and its scroll bars are updated.
  18903.  
  18904. Assembly-language note:  You can invoke each of the List Manager routines
  18905.                          with a macro that has the same name as the routine
  18906.                          preceded by an underscore. These macros expand to
  18907.                          invoke to trap macro _Pack 0. The package determines
  18908.                          which routine to execute from a routine selector, an
  18909.                          integer that’s passed to it in a word on the stack.
  18910.                          The routine selectors are as follows:
  18911.  
  18912.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  18913.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  18914.                            lAddRow     .EQU    8    lClick       .EQU    24
  18915.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  18916.                            lDelColumn  .EQU    32   lNew         .EQU    68
  18917.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  18918.                            lDispose    .EQU    40   lRect        .EQU    76
  18919.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  18920.                            lDraw       .EQU    48   lSearch      .EQU    84
  18921.                            lFind       .EQU    52   lSetCell     .EQU    88
  18922.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  18923.                            lGetSelect  .EQU    60   lSize        .EQU    96
  18924.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  18925.  
  18926. æKY LAddRow
  18927. æFp Lists.p
  18928. æT FUNCTION
  18929. æTN $A9E7
  18930. æD FUNCTION LAddRow(count: INTEGER;rowNum: INTEGER;lHandle: ListHandle): INTEGER;
  18931. æDT myVariable := LAddRow(count,rowNum,lHandle);
  18932. æRI LAddRow function  IV-271
  18933. æC 
  18934. LAddRow inserts the number of rows specified by the count parameter, starting at the
  18935. row specified by rowNum. Row numbers that are greater than or equal to rowNum are
  18936. increased by count. If rowNum is not within dataBounds, new last rows are added. The
  18937. number of the first added row is returned, and dataBounds.bottom is increased by
  18938. count. All cells added are empty. If there are no cells
  18939. (because dataBounds.left = dataBounds.right), no cells are added, but dataBounds is
  18940. still extended. If drawing is on and the added rows (which are empty) are visible,
  18941. the list and its scroll bars are updated.
  18942.  
  18943. Assembly-language note:  You can invoke each of the List Manager routines
  18944.                          with a macro that has the same name as the routine
  18945.                          preceded by an underscore. These macros expand to
  18946.                          invoke to trap macro _Pack 0. The package determines
  18947.                          which routine to execute from a routine selector, an
  18948.                          integer that’s passed to it in a word on the stack.
  18949.                          The routine selectors are as follows:
  18950.  
  18951.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  18952.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  18953.                            lAddRow     .EQU    8    lClick       .EQU    24
  18954.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  18955.                            lDelColumn  .EQU    32   lNew         .EQU    68
  18956.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  18957.                            lDispose    .EQU    40   lRect        .EQU    76
  18958.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  18959.                            lDraw       .EQU    48   lSearch      .EQU    84
  18960.                            lFind       .EQU    52   lSetCell     .EQU    88
  18961.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  18962.                            lGetSelect  .EQU    60   lSize        .EQU    96
  18963.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  18964.  
  18965. æKY LAddToCell
  18966. æFp Lists.p
  18967. æT PROCEDURE
  18968. æTN $A9E7
  18969. æD PROCEDURE LAddToCell(dataPtr: Ptr;dataLen: INTEGER;theCell: Cell;lHandle: ListHandle);
  18970. æDT LAddToCell(dataPtr,dataLen,theCell,lHandle);
  18971. æRI LAddToCell procedure  IV-272
  18972. æC 
  18973. LAddToCell appends the data pointed to by dataPtr and of length dataLen to the cell
  18974. specified by theCell in lHandle. If drawing is off, you must turn drawing on and call
  18975. LDraw (or LUpdate) to display the cell’s new value.
  18976.  
  18977. Assembly-language note:  You can invoke each of the List Manager routines
  18978.                          with a macro that has the same name as the routine
  18979.                          preceded by an underscore. These macros expand to
  18980.                          invoke to trap macro _Pack 0. The package determines
  18981.                          which routine to execute from a routine selector, an
  18982.                          integer that’s passed to it in a word on the stack.
  18983.                          The routine selectors are as follows:
  18984.  
  18985.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  18986.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  18987.                            lAddRow     .EQU    8    lClick       .EQU    24
  18988.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  18989.                            lDelColumn  .EQU    32   lNew         .EQU    68
  18990.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  18991.                            lDispose    .EQU    40   lRect        .EQU    76
  18992.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  18993.                            lDraw       .EQU    48   lSearch      .EQU    84
  18994.                            lFind       .EQU    52   lSetCell     .EQU    88
  18995.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  18996.                            lGetSelect  .EQU    60   lSize        .EQU    96
  18997.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  18998.  
  18999. æKY LAutoScroll
  19000. æFp Lists.p
  19001. æT PROCEDURE
  19002. æTN $A9E7
  19003. æD PROCEDURE LAutoScroll(lHandle: ListHandle);
  19004. æDT LAutoScroll(lHandle);
  19005. æRI LAutoScroll procedure  IV-275
  19006. æC 
  19007. For the given list, LAutoScroll scrolls the list until the first selected cell is
  19008. visible. It automatically places the first selected cell in the top left corner of
  19009. the visible rectangle.
  19010.  
  19011. Assembly-language note:  You can invoke each of the List Manager routines
  19012.                          with a macro that has the same name as the routine
  19013.                          preceded by an underscore. These macros expand to
  19014.                          invoke to trap macro _Pack 0. The package determines
  19015.                          which routine to execute from a routine selector, an
  19016.                          integer that’s passed to it in a word on the stack.
  19017.                          The routine selectors are as follows:
  19018.  
  19019.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19020.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19021.                            lAddRow     .EQU    8    lClick       .EQU    24
  19022.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19023.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19024.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19025.                            lDispose    .EQU    40   lRect        .EQU    76
  19026.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19027.                            lDraw       .EQU    48   lSearch      .EQU    84
  19028.                            lFind       .EQU    52   lSetCell     .EQU    88
  19029.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19030.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19031.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19032.  
  19033. æKY LCellSize
  19034. æFp Lists.p
  19035. æT PROCEDURE
  19036. æTN $A9E7
  19037. æD PROCEDURE LCellSize(cSize: Point;lHandle: ListHandle);
  19038. æDT LCellSize(cSize,lHandle);
  19039. æRI LCellSize procedure  IV-273
  19040. æC 
  19041. LCellSize sets the cellSize field in the list record to cSize and updates the visible
  19042. rectangle to contain cells of this size. This command should be used only before any
  19043. cells have been drawn.
  19044.  
  19045. Assembly-language note:  You can invoke each of the List Manager routines
  19046.                          with a macro that has the same name as the routine
  19047.                          preceded by an underscore. These macros expand to
  19048.                          invoke to trap macro _Pack 0. The package determines
  19049.                          which routine to execute from a routine selector, an
  19050.                          integer that’s passed to it in a word on the stack.
  19051.                          The routine selectors are as follows:
  19052.  
  19053.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19054.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19055.                            lAddRow     .EQU    8    lClick       .EQU    24
  19056.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19057.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19058.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19059.                            lDispose    .EQU    40   lRect        .EQU    76
  19060.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19061.                            lDraw       .EQU    48   lSearch      .EQU    84
  19062.                            lFind       .EQU    52   lSetCell     .EQU    88
  19063.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19064.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19065.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19066.  
  19067. æKY LClick
  19068. æFp Lists.p
  19069. æT FUNCTION
  19070. æTN $A9E7
  19071. æD FUNCTION LClick(pt: Point;modifiers: INTEGER;lHandle: ListHandle): BOOLEAN;
  19072. æDT myVariable := LClick(pt,modifiers,lHandle);
  19073. æRI LClick function  IV-273
  19074. æC 
  19075. Call LClick when there is a mouse-down event in the destination rectangle or its
  19076. scroll bars. Pt is the mouse location in local coordinates. Modifiers is the modifiers
  19077. word from the event record. LHandle is the list to be tracked. The result is TRUE if
  19078. a double-click occurred (and the two clicks took place within the same cell).
  19079.  
  19080. LClick keeps control until the mouse is released; each time through its inner loop,
  19081. it calls the routine whose pointer is in the lClikLoop field of the list record.
  19082.  
  19083. If the mouse is in the visible rectangle, cells are selected according to the state
  19084. of the modifiers and the selection flags. If the mouse was in the cells but is dragged
  19085. outside the list’s rectangle, the list is auto-scrolled. If the mouse was in a control,
  19086. the control’s definition procedure is called to track the mouse. To discover which
  19087. cell was clicked in, use the LLastClick function.
  19088.  
  19089. Assembly-language note:  You can invoke each of the List Manager routines
  19090.                          with a macro that has the same name as the routine
  19091.                          preceded by an underscore. These macros expand to
  19092.                          invoke to trap macro _Pack 0. The package determines
  19093.                          which routine to execute from a routine selector, an
  19094.                          integer that’s passed to it in a word on the stack.
  19095.                          The routine selectors are as follows:
  19096.  
  19097.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19098.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19099.                            lAddRow     .EQU    8    lClick       .EQU    24
  19100.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19101.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19102.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19103.                            lDispose    .EQU    40   lRect        .EQU    76
  19104.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19105.                            lDraw       .EQU    48   lSearch      .EQU    84
  19106.                            lFind       .EQU    52   lSetCell     .EQU    88
  19107.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19108.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19109.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19110.  
  19111. æKY LClrCell
  19112. æFp Lists.p
  19113. æT PROCEDURE
  19114. æTN $A9E7
  19115. æD PROCEDURE LClrCell(theCell: Cell;lHandle: ListHandle);
  19116. æDT LClrCell(theCell,lHandle);
  19117. æRI LClrCell procedure  IV-272
  19118. æC 
  19119. LClrCell clears the contents of the specified cell (by setting the length to 0). If
  19120. theCell is not a valid cell, nothing is done. If drawing is off, you must turn drawing
  19121. on and call LDraw to display the cell’s new value (or simply call the Window Manager
  19122. procedure InvalRect).
  19123.  
  19124. Assembly-language note:  You can invoke each of the List Manager routines
  19125.                          with a macro that has the same name as the routine
  19126.                          preceded by an underscore. These macros expand to
  19127.                          invoke to trap macro _Pack 0. The package determines
  19128.                          which routine to execute from a routine selector, an
  19129.                          integer that’s passed to it in a word on the stack.
  19130.                          The routine selectors are as follows:
  19131.  
  19132.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19133.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19134.                            lAddRow     .EQU    8    lClick       .EQU    24
  19135.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19136.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19137.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19138.                            lDispose    .EQU    40   lRect        .EQU    76
  19139.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19140.                            lDraw       .EQU    48   lSearch      .EQU    84
  19141.                            lFind       .EQU    52   lSetCell     .EQU    88
  19142.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19143.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19144.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19145.  
  19146. æKY LDelColumn
  19147. æFp Lists.p
  19148. æT PROCEDURE
  19149. æTN $A9E7
  19150. æD PROCEDURE LDelColumn(count: INTEGER;colNum: INTEGER;lHandle: ListHandle);
  19151. æDT LDelColumn(count,colNum,lHandle);
  19152. æRI LDelColumn procedure  IV-271
  19153. æC 
  19154. LDelColumn deletes the number of columns specified by the count parameter, starting
  19155. with the column specified by colNum. Column numbers that are greater than colNum are
  19156. decreased by count. If colNum is not within dataBounds, nothing is done. DataBounds.right
  19157. is decreased by count. If drawing is on and the deleted columns were visible, the
  19158. list and its scroll bars are updated.
  19159.  
  19160. If count is 0, or
  19161.  
  19162.   colNum = dataBounds.left AND count > = dataBounds.right – dataBounds.left
  19163.  
  19164. all the data in the list is quickly deleted, dataBounds.right is set to dataBounds.left,
  19165. and the number of rows is left unchanged.
  19166.  
  19167. Assembly-language note:  You can invoke each of the List Manager routines
  19168.                          with a macro that has the same name as the routine
  19169.                          preceded by an underscore. These macros expand to
  19170.                          invoke to trap macro _Pack 0. The package determines
  19171.                          which routine to execute from a routine selector, an
  19172.                          integer that’s passed to it in a word on the stack.
  19173.                          The routine selectors are as follows:
  19174.  
  19175.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19176.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19177.                            lAddRow     .EQU    8    lClick       .EQU    24
  19178.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19179.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19180.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19181.                            lDispose    .EQU    40   lRect        .EQU    76
  19182.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19183.                            lDraw       .EQU    48   lSearch      .EQU    84
  19184.                            lFind       .EQU    52   lSetCell     .EQU    88
  19185.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19186.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19187.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19188.  
  19189. æKY LDelRow
  19190. æFp Lists.p
  19191. æT PROCEDURE
  19192. æTN $A9E7
  19193. æD PROCEDURE LDelRow(count: INTEGER;rowNum: INTEGER;lHandle: ListHandle);
  19194. æDT LDelRow(count,rowNum,lHandle);
  19195. æRI LDelRow procedure  IV-272
  19196. æC 
  19197. LDelRow deletes the number of rows specified by the count parameter, starting with
  19198. the row specified by rowNum. Row numbers that are greater than rowNum are decreased
  19199. by count. If rowNum is not within dataBounds, nothing is done. DataBounds.bottom is
  19200. decreased by count. If drawing is on and the deleted rows were visible, the list and
  19201. its scroll bars are updated.
  19202.  
  19203. If count is 0, or
  19204.  
  19205.   rowNum = dataBounds.top AND count > = dataBounds.bottom – dataBounds.top
  19206.  
  19207. all the data in the list is quickly deleted, dataBounds.bottom is set to dataBounds.top,
  19208. and the number of columns is left unchanged.
  19209.  
  19210. Assembly-language note:  You can invoke each of the List Manager routines
  19211.                          with a macro that has the same name as the routine
  19212.                          preceded by an underscore. These macros expand to
  19213.                          invoke to trap macro _Pack 0. The package determines
  19214.                          which routine to execute from a routine selector, an
  19215.                          integer that’s passed to it in a word on the stack.
  19216.                          The routine selectors are as follows:
  19217.  
  19218.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19219.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19220.                            lAddRow     .EQU    8    lClick       .EQU    24
  19221.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19222.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19223.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19224.                            lDispose    .EQU    40   lRect        .EQU    76
  19225.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19226.                            lDraw       .EQU    48   lSearch      .EQU    84
  19227.                            lFind       .EQU    52   lSetCell     .EQU    88
  19228.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19229.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19230.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19231.  
  19232. æKY LDispose
  19233. æFp Lists.p
  19234. æT PROCEDURE
  19235. æTN $A9E7
  19236. æD PROCEDURE LDispose(lHandle: ListHandle);
  19237. æDT LDispose(lHandle);
  19238. æRI LDispose procedure  IV-271
  19239. æC 
  19240. Call LDispose when you are through using a list. It issues a close call to the list
  19241. definition procedure, and calls the Memory Manager procedure DisposHandle for the
  19242. data handle, the Control Manager procedure DisposeControl for both scroll bars (if
  19243. they’re there), and DisposHandle for the list record.
  19244.  
  19245. Note:  Calling LDispose is much faster than deleting one row at a time.
  19246.  
  19247. Assembly-language note:  You can invoke each of the List Manager routines
  19248.                          with a macro that has the same name as the routine
  19249.                          preceded by an underscore. These macros expand to
  19250.                          invoke to trap macro _Pack 0. The package determines
  19251.                          which routine to execute from a routine selector, an
  19252.                          integer that’s passed to it in a word on the stack.
  19253.                          The routine selectors are as follows:
  19254.  
  19255.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19256.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19257.                            lAddRow     .EQU    8    lClick       .EQU    24
  19258.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19259.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19260.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19261.                            lDispose    .EQU    40   lRect        .EQU    76
  19262.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19263.                            lDraw       .EQU    48   lSearch      .EQU    84
  19264.                            lFind       .EQU    52   lSetCell     .EQU    88
  19265.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19266.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19267.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19268.  
  19269. æKY LDoDraw
  19270. æFp Lists.p
  19271. æT PROCEDURE
  19272. æTN $A9E7
  19273. æD PROCEDURE LDoDraw(drawIt: BOOLEAN;lHandle: ListHandle);
  19274. æDT LDoDraw(drawIt,lHandle);
  19275. æRI LDoDraw procedure  IV-275 
  19276. æC 
  19277. LDoDraw sets the List Manager’s drawing mode to the state specified by drawIt. If
  19278. drawIt is TRUE, changes made by most List Manager calls will cause some sort of
  19279. drawing to take place. If drawIt is FALSE, all cell drawing is disabled.
  19280. (Two exceptions:  The scroll bars are still updated after LSize, and the scroll
  19281. arrows are still highlighted if the user clicks them.)
  19282.  
  19283. The recommended use of LDoDraw is to disable drawing while you’re building a list
  19284. (that is, adding rows or columns, setting or changing cell values, or setting default
  19285. selections). Once you’ve finished building the list, you should then re-enable drawing.
  19286. In general, drawing should be on while you’re in your event loop and dispatching
  19287. events to the List Manager.
  19288.  
  19289. Assembly-language note:  You can invoke each of the List Manager routines
  19290.                          with a macro that has the same name as the routine
  19291.                          preceded by an underscore. These macros expand to
  19292.                          invoke to trap macro _Pack 0. The package determines
  19293.                          which routine to execute from a routine selector, an
  19294.                          integer that’s passed to it in a word on the stack.
  19295.                          The routine selectors are as follows:
  19296.  
  19297.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19298.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19299.                            lAddRow     .EQU    8    lClick       .EQU    24
  19300.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19301.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19302.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19303.                            lDispose    .EQU    40   lRect        .EQU    76
  19304.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19305.                            lDraw       .EQU    48   lSearch      .EQU    84
  19306.                            lFind       .EQU    52   lSetCell     .EQU    88
  19307.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19308.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19309.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19310.  
  19311. æKY lDoHAutoscroll,lDoVAutoscroll
  19312. æFp Lists.p
  19313. æC 
  19314.   { Masks for automatic scrolling }
  19315.  
  19316.   lDoVAutoscroll    = 2      {set to allow automatic vertical scrolling}
  19317.   lDoHAutoscroll    = 1      {set to allow automatic horizontal scrolling}
  19318.  
  19319. æKY LDraw
  19320. æFp Lists.p
  19321. æT PROCEDURE
  19322. æTN $A9E7
  19323. æD PROCEDURE LDraw(theCell: Cell;lHandle: ListHandle);
  19324. æDT LDraw(theCell,lHandle);
  19325. æRI LDraw procedure  IV-275 
  19326. æC 
  19327. Call LDraw after updating a cell’s data or selection status. (You can achieve the
  19328. same result by invalidating the cell’s rectangle and calling LUpdate in response to
  19329. the update event.) The List Manager makes its grafPort the current port, sets the
  19330. clipping region to the cell’s rectangle, and calls the list definition procedure to
  19331. draw the cell. It restores the clipping region and port before exiting.
  19332.  
  19333. Assembly-language note:  You can invoke each of the List Manager routines
  19334.                          with a macro that has the same name as the routine
  19335.                          preceded by an underscore. These macros expand to
  19336.                          invoke to trap macro _Pack 0. The package determines
  19337.                          which routine to execute from a routine selector, an
  19338.                          integer that’s passed to it in a word on the stack.
  19339.                          The routine selectors are as follows:
  19340.  
  19341.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19342.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19343.                            lAddRow     .EQU    8    lClick       .EQU    24
  19344.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19345.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19346.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19347.                            lDispose    .EQU    40   lRect        .EQU    76
  19348.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19349.                            lDraw       .EQU    48   lSearch      .EQU    84
  19350.                            lFind       .EQU    52   lSetCell     .EQU    88
  19351.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19352.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19353.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19354.  
  19355. æKY LFind
  19356. æFp Lists.p
  19357. æT PROCEDURE
  19358. æTN $A9E7
  19359. æD PROCEDURE LFind(VAR offset: INTEGER;VAR len: INTEGER;theCell: Cell;lHandle: ListHandle);
  19360. æDT LFind(offset,len,theCell,lHandle);
  19361. æRI LFind procedure  IV-274
  19362. æC  
  19363. Given a cell in theCell, LFind returns the offset and the length in bytes of the
  19364. cell’s data. If an invalid cell is specified, offset and len are set to –1. A similar
  19365. procedure, LGetCell, is more convenient to use from Pascal.
  19366.  
  19367. Assembly-language note:  You can invoke each of the List Manager routines
  19368.                          with a macro that has the same name as the routine
  19369.                          preceded by an underscore. These macros expand to
  19370.                          invoke to trap macro _Pack 0. The package determines
  19371.                          which routine to execute from a routine selector, an
  19372.                          integer that’s passed to it in a word on the stack.
  19373.                          The routine selectors are as follows:
  19374.  
  19375.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19376.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19377.                            lAddRow     .EQU    8    lClick       .EQU    24
  19378.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19379.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19380.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19381.                            lDispose    .EQU    40   lRect        .EQU    76
  19382.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19383.                            lDraw       .EQU    48   lSearch      .EQU    84
  19384.                            lFind       .EQU    52   lSetCell     .EQU    88
  19385.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19386.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19387.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19388.  
  19389. æKY LGetCell
  19390. æFp Lists.p
  19391. æT PROCEDURE
  19392. æTN $A9E7
  19393. æD PROCEDURE LGetCell(dataPtr: Ptr;VAR dataLen: INTEGER;theCell: Cell;lHandle: ListHandle);
  19394. æDT LGetCell(dataPtr,dataLen,theCell,lHandle);
  19395. æRI LGetCell procedure  IV-272
  19396. æC 
  19397. Given a cell in theCell, LGetCell copies the cell’s data to the location specified by
  19398. dataPtr; dataLen is the maximum number of bytes allowed. If the data is longer than
  19399. dataLen, only dataLen bytes are copied into the location specified by dataPtr. If the
  19400. data is shorter than dataLen, dataLen is set to the true length of the cell’s data.
  19401.  
  19402. Assembly-language note:  You can invoke each of the List Manager routines
  19403.                          with a macro that has the same name as the routine
  19404.                          preceded by an underscore. These macros expand to
  19405.                          invoke to trap macro _Pack 0. The package determines
  19406.                          which routine to execute from a routine selector, an
  19407.                          integer that’s passed to it in a word on the stack.
  19408.                          The routine selectors are as follows:
  19409.  
  19410.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19411.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19412.                            lAddRow     .EQU    8    lClick       .EQU    24
  19413.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19414.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19415.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19416.                            lDispose    .EQU    40   lRect        .EQU    76
  19417.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19418.                            lDraw       .EQU    48   lSearch      .EQU    84
  19419.                            lFind       .EQU    52   lSetCell     .EQU    88
  19420.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19421.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19422.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19423.  
  19424. æKY LGetSelect
  19425. æFp Lists.p
  19426. æT FUNCTION
  19427. æTN $A9E7
  19428. æD FUNCTION LGetSelect(next: BOOLEAN;VAR theCell: Cell;lHandle: ListHandle): BOOLEAN;
  19429. æDT myVariable := LGetSelect(next,theCell,lHandle);
  19430. æRI LGetSelect function  IV-273
  19431. æC 
  19432. If next is FALSE, LGetSelect returns TRUE if the specified cell is selected, or FALSE
  19433. if not. If next is TRUE, LGetSelect returns in c the cell coordinates of the next
  19434. selected cell in the row that is greater than or equal to theCell. If there are no
  19435. more cells in the row, it returns in theCell the cell coordinates of the next selected
  19436. cell in the next row. If there are no more rows, FALSE is returned.
  19437.  
  19438. Assembly-language note:  You can invoke each of the List Manager routines
  19439.                          with a macro that has the same name as the routine
  19440.                          preceded by an underscore. These macros expand to
  19441.                          invoke to trap macro _Pack 0. The package determines
  19442.                          which routine to execute from a routine selector, an
  19443.                          integer that’s passed to it in a word on the stack.
  19444.                          The routine selectors are as follows:
  19445.  
  19446.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19447.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19448.                            lAddRow     .EQU    8    lClick       .EQU    24
  19449.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19450.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19451.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19452.                            lDispose    .EQU    40   lRect        .EQU    76
  19453.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19454.                            lDraw       .EQU    48   lSearch      .EQU    84
  19455.                            lFind       .EQU    52   lSetCell     .EQU    88
  19456.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19457.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19458.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19459.  
  19460. æKY lInitMsg,lDrawMsg,lHiliteMsg,lCloseMsg
  19461. æFp Lists.p
  19462. æC 
  19463.   { Messages to list definition procedure }
  19464.  
  19465.   lInitMsg          = 0;     {initialize list, set defaults, allocate space}
  19466.   lDrawMsg          = 1;     {draw the indicated cell data}
  19467.   lHiliteMsg        = 2;     {invert (select/deselect) the state of a cell}
  19468.   lCloseMsg         = 3;     {dispose of list and any associated data}
  19469.  
  19470. æKY LLastClick
  19471. æFp Lists.p
  19472. æT FUNCTION
  19473. æTN $A9E7
  19474. æD FUNCTION LLastClick(lHandle: ListHandle): Cell;
  19475. æDT myVariable := LLastClick(lHandle);
  19476. æRI LLastClick function  IV-273
  19477. æC 
  19478. LLastClick returns the cell coordinates of the last cell clicked in. If no cell has
  19479. been clicked in since LNew, the value returned (for both integers) is negative.
  19480.  
  19481. Note:  The value returned by this call is not the last cell double-clicked
  19482.        in, or the last cell selected, but merely the last cell clicked in.
  19483.  
  19484. Assembly-language note:  You can invoke each of the List Manager routines
  19485.                          with a macro that has the same name as the routine
  19486.                          preceded by an underscore. These macros expand to
  19487.                          invoke to trap macro _Pack 0. The package determines
  19488.                          which routine to execute from a routine selector, an
  19489.                          integer that’s passed to it in a word on the stack.
  19490.                          The routine selectors are as follows:
  19491.  
  19492.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19493.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19494.                            lAddRow     .EQU    8    lClick       .EQU    24
  19495.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19496.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19497.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19498.                            lDispose    .EQU    40   lRect        .EQU    76
  19499.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19500.                            lDraw       .EQU    48   lSearch      .EQU    84
  19501.                            lFind       .EQU    52   lSetCell     .EQU    88
  19502.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19503.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19504.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19505.  
  19506. æKY LNew
  19507. æFp Lists.p
  19508. æT FUNCTION
  19509. æTN $A9E7
  19510. æD FUNCTION LNew(rView: Rect;dataBounds: Rect;cSize: Point;theProc: INTEGER;
  19511.     theWindow: WindowPtr;drawIt: BOOLEAN;hasGrow: BOOLEAN;scrollHoriz: BOOLEAN;
  19512.     scrollVert: BOOLEAN): ListHandle;
  19513. æDT myVariable := LNew(rView,dataBounds,cSize,theProc,theWindow,drawIt,hasGrow,
  19514.     scrollHoriz,scrollVert);
  19515. æRI LNew function  IV-270
  19516. æC 
  19517. Call LNew to create a new list. It returns a handle to the new list. The list’s
  19518. grafPort is set to theWindow’s port. If drawIt is FALSE, the list is not displayed.
  19519.  
  19520. RView specifies, in the local coordinates of theWindow, the rectangle in which the
  19521. list will be displayed. (Remember that this doesn’t include space for scroll bars. If
  19522. the list, including scroll bars, is to fill the entire window, rView should be 15
  19523. points smaller in each dimension than theWindow’s portRect.)
  19524.  
  19525. DataBounds is the rectangle for specifying the initial array dimensions of the list.
  19526. For example to preallocate space for a list that’s 5 cells across by 10 cells down,
  19527. you should set dataBounds to (0,0)(5,10). If you want to allocate the space for a
  19528. one-column list, set dataBounds to (0,0)(1,0) and use LAddRow.
  19529.  
  19530. CSize.h and cSize.v are the desired height and width of each cell in pixels; if
  19531. they’re not specified, a default cell size is calculated (as described above).
  19532.  
  19533. TheProc is the resource ID of your list definition procedure; for a text-only list,
  19534. pass 0 and the default list definition procedure (about 150 bytes in size) will be
  19535. used. The list definition procedure is called to initialize itself after all other
  19536. list record fields have been initialized; thus, it can use any of the values in the
  19537. list record (or set particular fields, such as the indent distance).
  19538.  
  19539. If hasGrow is TRUE, the scroll bars are sized so that there’s room for a size box in
  19540. the standard position. It’s up to the program to display the size box
  19541. (using the Window Manager procedure DrawGrowIcon). If scrollHoriz is TRUE, a horizontal
  19542. scroll bar is placed immediately below rView and all horizontal scrolling functions
  19543. are implemented. If scrollVert is TRUE, a vertical scroll bar is placed immediately
  19544. to the right of rView and all vertical scrolling functions are implemented.
  19545.  
  19546. The visible rectangle is set to contain as many cells of cSize (or the default) as
  19547. will fit into rView. If the cells do not fit exactly into rView, the visible rectangle
  19548. is rounded up to the nearest cell. Scrolling will always allow all cells to be fully
  19549. displayed. The selection flags are set to 0, and the active flag is set to TRUE.
  19550.  
  19551. Note:  Scrolling looks best if rView is a multiple of cSize.v in height.
  19552.  
  19553. Assembly-language note:  You can invoke each of the List Manager routines
  19554.                          with a macro that has the same name as the routine
  19555.                          preceded by an underscore. These macros expand to
  19556.                          invoke to trap macro _Pack 0. The package determines
  19557.                          which routine to execute from a routine selector, an
  19558.                          integer that’s passed to it in a word on the stack.
  19559.                          The routine selectors are as follows:
  19560.  
  19561.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19562.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19563.                            lAddRow     .EQU    8    lClick       .EQU    24
  19564.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19565.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19566.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19567.                            lDispose    .EQU    40   lRect        .EQU    76
  19568.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19569.                            lDraw       .EQU    48   lSearch      .EQU    84
  19570.                            lFind       .EQU    52   lSetCell     .EQU    88
  19571.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19572.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19573.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19574.  
  19575. æKY LNextCell
  19576. æFp Lists.p
  19577. æT FUNCTION
  19578. æTN $A9E7
  19579. æD FUNCTION LNextCell(hNext: BOOLEAN;vNext: BOOLEAN;VAR theCell: Cell;lHandle: ListHandle): BOOLEAN;
  19580. æDT myVariable := LNextCell(hNext,vNext,theCell,lHandle);
  19581. æRI LNextCell function  IV-274
  19582. æC 
  19583. Given a cell in theCell, LNextCell returns in theCell the next cell in the list. If
  19584. both hNext and vNext are TRUE, theCell is first advanced to the next cell in the row.
  19585. If there are no more cells in the row, theCell is set to the first cell in the next
  19586. row. If there are no more rows, FALSE is returned. If only hNext is TRUE, theCell is
  19587. advanced within the current row. If only vNext is TRUE, theCell is advanced within
  19588. the current column. FALSE is returned if there are no remaining cells in the row or
  19589. column.
  19590.  
  19591. Assembly-language note:  You can invoke each of the List Manager routines
  19592.                          with a macro that has the same name as the routine
  19593.                          preceded by an underscore. These macros expand to
  19594.                          invoke to trap macro _Pack 0. The package determines
  19595.                          which routine to execute from a routine selector, an
  19596.                          integer that’s passed to it in a word on the stack.
  19597.                          The routine selectors are as follows:
  19598.  
  19599.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19600.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19601.                            lAddRow     .EQU    8    lClick       .EQU    24
  19602.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19603.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19604.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19605.                            lDispose    .EQU    40   lRect        .EQU    76
  19606.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19607.                            lDraw       .EQU    48   lSearch      .EQU    84
  19608.                            lFind       .EQU    52   lSetCell     .EQU    88
  19609.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19610.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19611.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19612.  
  19613.  
  19614. æKY lOnlyOne,lExtendDrag,lNoDisjoint,lNoExtend,lNoRect,lUseSense,lNoNilHilite
  19615. æFp Lists.p
  19616. æC 
  19617.   { Masks for selection flags }
  19618.  
  19619.   lOnlyOne          = –128;  {set if only one selection at a time}
  19620.   lExtendDrag       = 64;    {set for dragging without Shift key}
  19621.   lNoDisjoint       = 32;    {set to turn off multiple selections with click}
  19622.   lNoExtend         = 16;    {set to not extend Shift selections}
  19623.   lNoRect           = 8;     {set to not grow selections as rectangles}
  19624.   lUseSense         = 4;     {set for Shift to use sense of first cell}
  19625.   lNoNilHilite      = 2;     {set to not highlight empty cells}
  19626.  
  19627. æKY LRect
  19628. æFp Lists.p
  19629. æT PROCEDURE
  19630. æTN $A9E7
  19631. æD PROCEDURE LRect(VAR cellRect: Rect;theCell: Cell;lHandle: ListHandle);
  19632. æDT LRect(cellRect,theCell,lHandle);
  19633. æRI LRect procedure  IV-274
  19634. æC 
  19635. LRect returns in cellRect the local (QuickDraw) coordinates of the cell specified by
  19636. theCell. If an invalid cell is specified, (0,0)(0,0) is returned in cellRect.
  19637.  
  19638. Assembly-language note:  You can invoke each of the List Manager routines
  19639.                          with a macro that has the same name as the routine
  19640.                          preceded by an underscore. These macros expand to
  19641.                          invoke to trap macro _Pack 0. The package determines
  19642.                          which routine to execute from a routine selector, an
  19643.                          integer that’s passed to it in a word on the stack.
  19644.                          The routine selectors are as follows:
  19645.  
  19646.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19647.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19648.                            lAddRow     .EQU    8    lClick       .EQU    24
  19649.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19650.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19651.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19652.                            lDispose    .EQU    40   lRect        .EQU    76
  19653.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19654.                            lDraw       .EQU    48   lSearch      .EQU    84
  19655.                            lFind       .EQU    52   lSetCell     .EQU    88
  19656.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19657.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19658.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19659.  
  19660. æKY LScroll
  19661. æFp Lists.p
  19662. æT PROCEDURE
  19663. æTN $A9E7
  19664. æD PROCEDURE LScroll(dCols: INTEGER;dRows: INTEGER;lHandle: ListHandle);
  19665. æDT LScroll(dCols,dRows,lHandle);
  19666. æRI LScroll procedure  IV-275 
  19667. æC 
  19668. LScroll scrolls the given list by the number of columns and rows specified in dCols
  19669. and dRows, either positively (down and to the right) or negatively (up and to the
  19670. left). Scrolling is pinned to the list’s dataBounds. If drawing is on, LScroll does
  19671. all necessary updating of the screen.
  19672.  
  19673. Assembly-language note:  You can invoke each of the List Manager routines
  19674.                          with a macro that has the same name as the routine
  19675.                          preceded by an underscore. These macros expand to
  19676.                          invoke to trap macro _Pack 0. The package determines
  19677.                          which routine to execute from a routine selector, an
  19678.                          integer that’s passed to it in a word on the stack.
  19679.                          The routine selectors are as follows:
  19680.  
  19681.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19682.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19683.                            lAddRow     .EQU    8    lClick       .EQU    24
  19684.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19685.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19686.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19687.                            lDispose    .EQU    40   lRect        .EQU    76
  19688.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19689.                            lDraw       .EQU    48   lSearch      .EQU    84
  19690.                            lFind       .EQU    52   lSetCell     .EQU    88
  19691.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19692.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19693.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19694.  
  19695. æKY LSearch
  19696. æFp Lists.p
  19697. æT FUNCTION
  19698. æTN $A9E7
  19699. æD FUNCTION LSearch(dataPtr: Ptr;dataLen: INTEGER;searchProc: ProcPtr;VAR theCell: Cell;
  19700.     lHandle: ListHandle): BOOLEAN;
  19701. æDT myVariable := LSearch(dataPtr,dataLen,searchProc,theCell,lHandle);
  19702. æRI LSearch function  IV-274 
  19703. æC 
  19704. LSearch searches for the first cell greater than or equal to theCell that contains
  19705. the specified data. If a cell containing matching data is found, the function result
  19706. TRUE is returned, and the cell coordinates are returned in theCell. If searchProc is
  19707. NIL, the International Utilities Package function IUMagIDString is called to compare
  19708. the specified data with the contents of each cell. If searchProc is not NIL, the
  19709. routine pointed to by searchProc is called.
  19710.  
  19711. Note:  Your searchProc should have the same parameters as the
  19712.        IUMagIDString function.
  19713.  
  19714. Assembly-language note:  You can invoke each of the List Manager routines
  19715.                          with a macro that has the same name as the routine
  19716.                          preceded by an underscore. These macros expand to
  19717.                          invoke to trap macro _Pack 0. The package determines
  19718.                          which routine to execute from a routine selector, an
  19719.                          integer that’s passed to it in a word on the stack.
  19720.                          The routine selectors are as follows:
  19721.  
  19722.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19723.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19724.                            lAddRow     .EQU    8    lClick       .EQU    24
  19725.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19726.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19727.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19728.                            lDispose    .EQU    40   lRect        .EQU    76
  19729.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19730.                            lDraw       .EQU    48   lSearch      .EQU    84
  19731.                            lFind       .EQU    52   lSetCell     .EQU    88
  19732.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19733.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19734.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19735.  
  19736. æKY LSetCell
  19737. æFp Lists.p
  19738. æT PROCEDURE
  19739. æTN $A9E7
  19740. æD PROCEDURE LSetCell(dataPtr: Ptr;dataLen: INTEGER;theCell: Cell;lHandle: ListHandle);
  19741. æDT LSetCell(dataPtr,dataLen,theCell,lHandle);
  19742. æRI LSetCell procedure  IV-272
  19743. æC 
  19744. LSetCell places the data pointed to by dataPtr and of length dataLen into the specified
  19745. cell. It replaces any data that was already in the cell. If dataLen is 0, this is
  19746. equivalent to LClrCell. If theCell is not a valid cell, nothing is done. If drawing
  19747. is off, you must turn drawing on and call LDraw (or LUpdate) to display the cell’s
  19748. new value.
  19749.  
  19750. Assembly-language note:  You can invoke each of the List Manager routines
  19751.                          with a macro that has the same name as the routine
  19752.                          preceded by an underscore. These macros expand to
  19753.                          invoke to trap macro _Pack 0. The package determines
  19754.                          which routine to execute from a routine selector, an
  19755.                          integer that’s passed to it in a word on the stack.
  19756.                          The routine selectors are as follows:
  19757.  
  19758.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19759.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19760.                            lAddRow     .EQU    8    lClick       .EQU    24
  19761.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19762.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19763.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19764.                            lDispose    .EQU    40   lRect        .EQU    76
  19765.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19766.                            lDraw       .EQU    48   lSearch      .EQU    84
  19767.                            lFind       .EQU    52   lSetCell     .EQU    88
  19768.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19769.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19770.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19771.  
  19772. æKY LSetSelect
  19773. æFp Lists.p
  19774. æT PROCEDURE
  19775. æTN $A9E7
  19776. æD PROCEDURE LSetSelect(setIt: BOOLEAN;theCell: Cell;lHandle: ListHandle);
  19777. æDT LSetSelect(setIt,theCell,lHandle);
  19778. æRI LSetSelect procedure  IV-273
  19779. æC 
  19780. If setIt is TRUE, LSetSelect selects the cell and redraws if it is visible and was
  19781. previously unselected. If setIt is FALSE, it deselects the cell and redraws if necessary.
  19782.  
  19783. Assembly-language note:  You can invoke each of the List Manager routines
  19784.                          with a macro that has the same name as the routine
  19785.                          preceded by an underscore. These macros expand to
  19786.                          invoke to trap macro _Pack 0. The package determines
  19787.                          which routine to execute from a routine selector, an
  19788.                          integer that’s passed to it in a word on the stack.
  19789.                          The routine selectors are as follows:
  19790.  
  19791.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19792.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19793.                            lAddRow     .EQU    8    lClick       .EQU    24
  19794.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19795.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19796.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19797.                            lDispose    .EQU    40   lRect        .EQU    76
  19798.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19799.                            lDraw       .EQU    48   lSearch      .EQU    84
  19800.                            lFind       .EQU    52   lSetCell     .EQU    88
  19801.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19802.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19803.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19804.  
  19805. æKY LSize
  19806. æFp Lists.p
  19807. æT PROCEDURE
  19808. æTN $A9E7
  19809. æD PROCEDURE LSize(listWidth: INTEGER;listHeight: INTEGER;lHandle: ListHandle);
  19810. æDT LSize(listWidth,listHeight,lHandle);
  19811. æRI LSize procedure  IV-274 
  19812. æC 
  19813. You’ll usually call LSize immediately after the Window Manager procedure SizeWindow.
  19814. It causes the bottom right of the list to be adjusted so that the list is the width
  19815. and height indicated by listWidth and listHeight. The contents of the list and the
  19816. scroll bars are adjusted and redrawn as necessary. The values of listWidth and listHeight
  19817. do not include the scroll bars; for a list that entirely fills the window, listWidth
  19818. and listHeight should be 15 fewer pixels than the portRect if both scroll bars are
  19819. present.
  19820.  
  19821. Assembly-language note:  You can invoke each of the List Manager routines
  19822.                          with a macro that has the same name as the routine
  19823.                          preceded by an underscore. These macros expand to
  19824.                          invoke to trap macro _Pack 0. The package determines
  19825.                          which routine to execute from a routine selector, an
  19826.                          integer that’s passed to it in a word on the stack.
  19827.                          The routine selectors are as follows:
  19828.  
  19829.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19830.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19831.                            lAddRow     .EQU    8    lClick       .EQU    24
  19832.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19833.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19834.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19835.                            lDispose    .EQU    40   lRect        .EQU    76
  19836.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19837.                            lDraw       .EQU    48   lSearch      .EQU    84
  19838.                            lFind       .EQU    52   lSetCell     .EQU    88
  19839.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19840.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19841.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19842.  
  19843. æKY LUpdate
  19844. æFp Lists.p
  19845. æT PROCEDURE
  19846. æTN $A9E7
  19847. æD PROCEDURE LUpdate(theRgn: RgnHandle;lHandle: ListHandle);
  19848. æDT LUpdate(theRgn,lHandle);
  19849. æRI LUpdate procedure  IV-275
  19850. æC 
  19851. LUpdate should be called in response to an update event. TheRgn should be set to the
  19852. visRgn of the list’s port (for more details, see the BeginUpdate procedure in the
  19853. Window Manager chapter). It redraws any visible cells in lHandle that intersect
  19854. theRgn. It also redraws the controls, if necessary.
  19855.  
  19856. Assembly-language note:  You can invoke each of the List Manager routines
  19857.                          with a macro that has the same name as the routine
  19858.                          preceded by an underscore. These macros expand to
  19859.                          invoke to trap macro _Pack 0. The package determines
  19860.                          which routine to execute from a routine selector, an
  19861.                          integer that’s passed to it in a word on the stack.
  19862.                          The routine selectors are as follows:
  19863.  
  19864.                            lActivate   .EQU    0    lAutoScroll  .EQU    16
  19865.                            lAddColumn  .EQU    4    lCellSize    .EQU    20
  19866.                            lAddRow     .EQU    8    lClick       .EQU    24
  19867.                            lAddToCell  .EQU    12   lClrCell     .EQU    28
  19868.                            lDelColumn  .EQU    32   lNew         .EQU    68
  19869.                            lDelRow     .EQU    36   lNextCell    .EQU    72
  19870.                            lDispose    .EQU    40   lRect        .EQU    76
  19871.                            lDoDraw     .EQU    44   lScroll      .EQU    80
  19872.                            lDraw       .EQU    48   lSearch      .EQU    84
  19873.                            lFind       .EQU    52   lSetCell     .EQU    88
  19874.                            lGetCell    .EQU    56   lSetSelect   .EQU    92
  19875.                            lGetSelect  .EQU    60   lSize        .EQU    96
  19876.                            lLastClick  .EQU    64   lUpdate      .EQU    100
  19877.  
  19878.  
  19879. æKY Memory.p
  19880. æKL ApplicZone
  19881. BlockMove
  19882. CompactMem
  19883. DisposHandle
  19884. DisposPtr
  19885. EmptyHandle
  19886. FreeMem
  19887. GetApplLimit
  19888. GetHandleSize
  19889. GetPtrSize
  19890. GetZone
  19891. GZSaveHnd
  19892. HandleZone
  19893. HClrRBit
  19894. HGetState
  19895. HLock
  19896. HNoPurge
  19897. HPurge
  19898. HSetRBit
  19899. HSetState
  19900. HUnlock
  19901. InitApplZone
  19902. InitZone
  19903. MaxApplZone
  19904. MaxBlock
  19905. MaxMem
  19906. MemError
  19907. MFFreeMem
  19908. MFMaxMem
  19909. MFTempDisposHandle
  19910. MFTempHLock
  19911. MFTempHUnlock
  19912. MFTempNewHandle
  19913. MFTopMem
  19914. MoreMasters
  19915. MoveHHi
  19916. NewEmptyHandle
  19917. NewHandle
  19918. NewHandleClear
  19919. NewHandleSys
  19920. NewHandleSysClear
  19921. NewPtr
  19922. NewPtrClear
  19923. NewPtrSys
  19924. NewPtrSysClear
  19925. PtrZone
  19926. PurgeMem
  19927. PurgeSpace
  19928. ReallocHandle
  19929. RecoverHandle
  19930. ResrvMem
  19931. SetApplBase
  19932. SetApplLimit
  19933. SetGrowZone
  19934. SetHandleSize
  19935. SetPtrSize
  19936. SetZone
  19937. StackSpace
  19938. StripAddress
  19939. SystemZone
  19940. TopMem
  19941.  
  19942. maxSize
  19943. Size
  19944. THz
  19945. Zone
  19946.  
  19947. æKY Zone,THz
  19948. æFp Memory.p
  19949. æT TYPE
  19950. æC THz = ^Zone;
  19951. Zone = RECORD
  19952.    bkLim: Ptr;
  19953.    purgePtr: Ptr;
  19954.    hFstFree: Ptr;
  19955.    zcbFree: LONGINT;
  19956.    gzProc: ProcPtr;
  19957.    moreMast: INTEGER;
  19958.    flags: INTEGER;
  19959.    cntRel: INTEGER;
  19960.    maxRel: INTEGER;
  19961.    cntNRel: INTEGER;
  19962.    maxNRel: INTEGER;
  19963.    cntEmpty: INTEGER;
  19964.    cntHandles: INTEGER;
  19965.    minCBFree: LONGINT;
  19966.    purgeProc: ProcPtr;
  19967.    sparePtr: Ptr;
  19968.    allocPtr: Ptr;
  19969.    heapData: INTEGER;
  19970.    END;
  19971.  
  19972. »Structure of Heap Zones
  19973.  
  19974. Each heap zone begins with a 52-byte zone header and ends with a 12-byte zone trailer
  19975. (see Figure 11). The header contains all the information the Memory Manager needs
  19976. about that heap zone; the trailer is just a minimum-size free block (described in the
  19977. next section) placed at the end of the zone as a marker. All the remaining space
  19978. between the header and trailer is available for allocation.
  19979.  
  19980. In Pascal, a heap zone is defined as a zone record of type Zone. It’s always referred
  19981. to with a zone pointer of type THz (“the heap zone”):
  19982.  
  19983. TYPE  THz  = ^Zone;
  19984.       Zone = RECORD
  19985.                bkLim:       Ptr;      {zone trailer block}
  19986.                purgePtr:    Ptr;      {used internally}
  19987.                hFstFree:    Ptr;      {first free master pointer}
  19988.                zcbFree:     LONGINT;  {number of free bytes}
  19989.                gzProc:      ProcPtr;  {grow zone function}
  19990.                moreMast:    INTEGER;  {master pointers to allocate}
  19991.                flags:       INTEGER;  {used internally}
  19992.                cntRel:      INTEGER;  {not used}
  19993.                maxRel:      INTEGER;  {not used}
  19994.                cntNRel:     INTEGER;  {not used}
  19995.                maxNRel:     INTEGER;  {not used}
  19996.                cntEmpty:    INTEGER;  {not used}
  19997.                cntHandles:  INTEGER;  {not used}
  19998.                minCBFree:   LONGINT;  {not used}
  19999.                purgeProc:   ProcPtr;  {purge warning procedure}
  20000.                sparePtr:    Ptr;      {used internally}
  20001.                allocPtr:    Ptr;      {used internally}
  20002.                heapData:    INTEGER   {first usable byte in zone}
  20003.              END;
  20004.  
  20005. Warning:  The fields of the zone header are for the Memory Manager’s own
  20006.           internal use. You can examine the contents of the zone’s fields,
  20007.           but in general it doesn’t make sense for your program to try to
  20008.           change them. The few exceptions are noted below in the discussions
  20009.           of the specific fields.
  20010.  
  20011. BkLim is a pointer to the zone’s trailer block. Since the trailer is the last block
  20012. in the zone, bkLim is a pointer to the byte following the last byte of usable space
  20013. in the zone.
  20014.  
  20015. HFstFree is a pointer to the first free master pointer in the zone. Instead of just
  20016. allocating space for one master pointer each time a relocatable block is created, the
  20017. Memory Manager “preallocates” several master pointers at a time; as a group they form
  20018. a nonrelocatable block. The moreMast field of the zone record tells the Memory Manager
  20019. how many master pointers at a time to preallocate for this zone.
  20020.  
  20021. Note:  Master pointers are allocated 32 at a time for the system heap zone
  20022.        and 64 at a time for the application zone; this may be different on
  20023.        future versions of the Macintosh.
  20024.  
  20025. All master pointers that are allocated but not currently in use are linked together
  20026. into a list beginning in the hFstFree field. When you allocate a new relocatable
  20027. block, the Memory Manager removes the first available master pointer from this list,
  20028. sets it to point to the new block, and returns its address to you as a handle to the
  20029. block. (If the list is empty, it allocates a fresh block of moreMast master pointers.)
  20030. When you release a relocatable block, its master pointer isn’t released, but is
  20031. linked onto the beginning of the list to be reused. Thus the amount of space devoted
  20032. to master pointers can increase, but can never decrease until the zone is reinitialized.
  20033.  
  20034. The zcbFree field always contains the number of free bytes remaining in the zone. As
  20035. blocks are allocated and released, the Memory Manager adjusts zcbFree accordingly.
  20036. This number represents an upper limit on the size of block you can allocate from this
  20037. heap zone.
  20038.  
  20039. Warning:  It may not actually be possible to allocate a block as big as
  20040.           zcbFree bytes. Because nonrelocatable and locked blocks can’t be
  20041.           moved, it isn’t always possible to collect all the free space into
  20042.           a single block by compaction.
  20043.  
  20044. The gzProc field is a pointer to the grow zone function. You can supply a pointer to
  20045. your own grow zone function when you create a new heap zone and can change it at any
  20046. time.
  20047.  
  20048. Warning:  Don’t store directly into the gzProc field; if you want to supply
  20049.           your own grow zone function, you must do so with a procedure call
  20050.           (InitZone or SetGrowZone).
  20051.  
  20052. PurgeProc is a pointer to the zone’s purge warning procedure, or NIL if there is
  20053. none. The Memory Manager will call this procedure before it purges a block from the
  20054. zone.
  20055.  
  20056. Warning:  Whenever you call the Resource Manager with SetResPurge(TRUE),
  20057.           it installs its own purge warning procedure, overriding any purge
  20058.           warning procedure you’ve specified to the Memory Manager; for further
  20059.           details, see the Resource Manager chapter.
  20060.  
  20061. The last field of a zone record, heapData, is a dummy field marking the bottom of the
  20062. zone’s usable memory space.
  20063.  
  20064. HeapData nominally contains an integer, but this integer has no significance in
  20065. itself—it’s just the first two bytes in the block header of the first block in the
  20066. zone. The purpose of the heapData field is to give you a way of locating the effective
  20067. bottom of the zone. For example, if myZone is a zone pointer, then
  20068.  
  20069.   @(myZone^.heapData)
  20070.  
  20071. is a pointer to the first usable byte in the zone, just as
  20072.  
  20073.   myZone^.bkLim
  20074.  
  20075. is a pointer to the byte following the last usable byte in the zone.
  20076.  
  20077. æKY ApplicZone
  20078. æFp Memory.p
  20079. æT FUNCTION
  20080. æD FUNCTION ApplicZone: THz;
  20081. æDT myVariable := ApplicZone;
  20082. æRI ApplicZone function II-32, N83-1
  20083. æC  
  20084. [Not in ROM]
  20085.  
  20086. ApplicZone returns a pointer to the original application heap zone.
  20087.  
  20088. Assembly-language note:  The global variable ApplZone contains
  20089.                          a pointer to the original application heap zone.
  20090.  
  20091. æKY BlockMove
  20092. æFp Memory.p
  20093. æT PROCEDURE
  20094. æTN $A02E
  20095. æD PROCEDURE BlockMove(srcPtr: Ptr;destPtr: Ptr;byteCount: Size);
  20096. æDT BlockMove(srcPtr,destPtr,byteCount);
  20097. æRI BlockMove procedure II-44
  20098. æC 
  20099. Trap macro  _BlockMove
  20100. On entry    A0:  sourcePtr (pointer)
  20101.             A1:  destPtr (pointer)
  20102.             D0:  byteCount (long word)
  20103. On exit     D0:  result code (word)
  20104.  
  20105. BlockMove moves a block of byteCount consecutive bytes from the address designated by
  20106. sourcePtr to that designated by destPtr. No pointers are updated. BlockMove works
  20107. correctly even if the source and destination blocks overlap.
  20108.  
  20109. Result codes    noErr    No error
  20110.  
  20111. æKY CompactMem
  20112. æFp Memory.p
  20113. æT FUNCTION
  20114. æTN $A04C
  20115. æD FUNCTION CompactMem(cbNeeded: Size): Size;
  20116. æDT myVariable := CompactMem(cbNeeded);
  20117. æMM 
  20118. æRT 51
  20119. æRI CompactMem function II-39, N51-1
  20120. æC 
  20121. Trap macro  _CompactMem
  20122.             _CompactMem ,SYS (applies to system heap)
  20123. On entry    D0:  cbNeeded (long word)
  20124. On exit     D0:  function result (long word)
  20125.  
  20126. CompactMem compacts the current heap zone by moving relocatable blocks down and
  20127. collecting free space together until a contiguous block of at least cbNeeded free
  20128. bytes is found or the entire zone is compacted; it doesn’t purge any purgeable blocks.
  20129. CompactMem returns the size in bytes of the largest contiguous free block remaining.
  20130. Note that it doesn’t actually allocate the block.
  20131.  
  20132. Result codes    noErr    No error [Pascal only]
  20133.  
  20134. æKY DisposHandle
  20135. æFp Memory.p
  20136. æT PROCEDURE
  20137. æTN $A023
  20138. æD PROCEDURE DisposHandle(h: Handle);
  20139. æDT DisposHandle(h);
  20140. æMM   
  20141. æRI DisposHandle procedure I-76, 80, II-33, N8-1, P-51, 168
  20142. æC 
  20143. Trap macro  _DisposHandle
  20144. On entry    A0:  h (handle)
  20145. On exit     D0:  result code (word)
  20146.  
  20147. DisposHandle releases the memory occupied by the relocatable block whose handle is
  20148. h.
  20149.  
  20150. Warning:  After a call to DisposHandle, all handles to the released block
  20151.           become invalid and should not be used again. Any subsequent calls
  20152.           to DisposHandle using an invalid handle will damage the master
  20153.           pointer list.
  20154.  
  20155. Result codes    noErr       No error
  20156.                 memWZErr    Attempt to operate on a free block
  20157.  
  20158. æKY DisposPtr
  20159. æFp Memory.p
  20160. æT PROCEDURE
  20161. æTN $A01F
  20162. æD PROCEDURE DisposPtr(p: Ptr);
  20163. æDT DisposPtr(p);
  20164. æMM   
  20165. æRI DisposPtr procedure I-75, 79, II-36, P-51, 169
  20166. æC 
  20167. Trap macro  _DisposPtr
  20168. On entry    A0:  p (pointer)
  20169. On exit     D0:  result code (word)
  20170.  
  20171. DisposPtr releases the memory occupied by the nonrelocatable block pointed to by
  20172. p.
  20173.  
  20174. Warning:  After a call to DisposPtr, all pointers to the released block
  20175.           become invalid and should not be used again. Any subsequent calls
  20176.           to DisposPtr using an invalid pointer will damage the master
  20177.           pointer list.
  20178.  
  20179. Result codes    noErr       No error
  20180.                 memWZErr    Attempt to operate on a free block
  20181.  
  20182. æKY EmptyHandle
  20183. æFp Memory.p
  20184. æT PROCEDURE
  20185. æTN $A02B
  20186. æD PROCEDURE EmptyHandle(h: Handle);
  20187. æDT EmptyHandle(h);
  20188. æMM   
  20189. æRI EmptyHandle procedure  II-40
  20190. æC 
  20191. Trap macro  _EmptyHandle
  20192. On entry    A0:  h (handle)
  20193. On exit     A0:  h (handle)
  20194.             D0:  result code (word)
  20195.  
  20196. EmptyHandle purges the relocatable block whose handle is h from its heap zone and
  20197. sets its master pointer to NIL (making it an empty handle). If h is already empty,
  20198. EmptyHandle does nothing.
  20199.  
  20200. Note:  Since the space occupied by the block’s master pointer itself remains
  20201.        allocated, all handles pointing to it remain valid but empty. When you
  20202.        later reallocate space for the block with ReallocHandle, the master
  20203.        pointer will be updated, causing all existing handles to access the
  20204.        new block correctly.
  20205.  
  20206. The block whose handle is h must be unlocked, but need not be purgeable.
  20207.  
  20208. Result codes    noErr        No error
  20209.                 memWZErr     Attempt to operate on a free block
  20210.                 memPurErr    Attempt to purge a locked block
  20211.  
  20212. æKY FreeMem
  20213. æFp Memory.p
  20214. æT FUNCTION
  20215. æTN $A01C
  20216. æD FUNCTION FreeMem: LONGINT;
  20217. æDT myVariable := FreeMem;
  20218. æMM   
  20219. æRI FreeMem function  II-38
  20220. æC 
  20221. Trap macro  _FreeMem
  20222.             _FreeMem ,SYS (applies to system heap)
  20223. On exit     D0:  function result (long word)
  20224.  
  20225. FreeMem returns the total amount of free space in the current heap zone, in bytes.
  20226. Note that it usually isn’t possible to allocate a block of this size, because of
  20227. fragmentation due to nonrelocatable or locked blocks.
  20228.  
  20229. Result codes    noErr    No error [Pascal only]
  20230.  
  20231. æKY GetApplLimit
  20232. æFp Memory.p
  20233. æT FUNCTION
  20234. æD FUNCTION GetApplLimit: Ptr;
  20235. æDT myVariable := GetApplLimit;
  20236. æRI GetApplLimit function  II-29
  20237. æC 
  20238. GetApplLimit returns the current application heap limit. It can be used in conjunction
  20239. with SetApplLimit, described below, to determine and then change the application heap
  20240. limit.
  20241.  
  20242. Assembly-language note:  The global variable ApplLimit contains the
  20243.                          current application heap limit.
  20244.  
  20245. æKY GetHandleSize
  20246. æFp Memory.p
  20247. æT FUNCTION
  20248. æTN $A025
  20249. æD FUNCTION GetHandleSize(h: Handle): Size;
  20250. æDT myVariable := GetHandleSize(h);
  20251. æRI GetHandleSize function  II-33, N54-1, N63-1
  20252. æC 
  20253. Trap macro  _GetHandleSize
  20254. On entry    A0:    h (handle)
  20255. On exit     D0:    if >= 0, function result (long word)
  20256.                    if < 0, result code (word)
  20257.  
  20258. GetHandleSize returns the logical size, in bytes, of the relocatable block whose
  20259. handle is h. In case of an error, GetHandleSize returns 0.
  20260.  
  20261. Assembly-language note:  Recall that the trap dispatcher sets the condition
  20262.                          codes before returning from a trap by testing the
  20263.                          low-order word of register D0 with a TST.W instruction.
  20264.                          Since the block size returned in D0 by _GetHandleSize
  20265.                          is a full 32-bit long word, the word-length test sets
  20266.                          the condition codes incorrectly in this case. To
  20267.                          branch on the contents of D0, use your own TST.L
  20268.                          instruction on return from the trap to test the full
  20269.                          32 bits of the register.
  20270.  
  20271. Result codes    noErr           No error [Pascal only]
  20272.                 nilHandleErr    NIL master pointer
  20273.                 memWZErr        Attempt to operate on a free block
  20274.  
  20275. æKY GetPtrSize
  20276. æFp Memory.p
  20277. æT FUNCTION
  20278. æTN $A021
  20279. æD FUNCTION GetPtrSize(p: Ptr): Size;
  20280. æDT myVariable := GetPtrSize(p);
  20281. æRI GetPtrSize function  II-37
  20282. æC 
  20283. Trap macro  _GetPtrSize
  20284. On entry    A0:    p (pointer)
  20285. On exit     D0:    if >= 0, function result (long word)
  20286.                    if < 0, result code (word)
  20287.  
  20288. GetPtrSize returns the logical size, in bytes, of the nonrelocatable block pointed to
  20289. by p. In case of an error, GetPtrSize returns 0.
  20290.  
  20291. Assembly-language note:  Recall that the trap dispatcher sets the condition
  20292.                          codes before returning from a trap by testing the
  20293.                          low-order word of register D0 with a TST.W instruction.
  20294.                          Since the block size returned in D0 by _GetPtrSize is
  20295.                          a full 32-bit long word, the word-length test sets the
  20296.                          condition codes incorrectly in this case. To branch on
  20297.                          the contents of D0, use your own TST.L instruction on
  20298.                          return from the trap to test the full 32 bits of the
  20299.                          register.
  20300.  
  20301. Result codes    noErr       No error [Pascal only]
  20302.                 memWZErr    Attempt to operate on a free block
  20303.  
  20304. æKY GetZone
  20305. æFp Memory.p
  20306. æT FUNCTION
  20307. æTN $A11A
  20308. æD FUNCTION GetZone: THz;
  20309. æDT myVariable := GetZone;
  20310. æRI GetZone function  II-31
  20311. æC 
  20312. Trap macro  _GetZone
  20313. On exit     A0:  function result (pointer)
  20314.             D0:  result code (word)
  20315.  
  20316. GetZone returns a pointer to the current heap zone.
  20317.  
  20318. Assembly-language note:  The global variable TheZone contains a
  20319.                          pointer to the current heap zone.
  20320.  
  20321. Result codes    noErr    No error
  20322.  
  20323. æKY GZSaveHnd
  20324. æFp Memory.p
  20325. æT FUNCTION
  20326. æD FUNCTION GZSaveHnd: Handle;
  20327. æDT myVariable := GZSaveHnd;
  20328. æRI GZSaveHnd function  II-43
  20329. æC  
  20330. GZSaveHnd returns a handle to a relocatable block that must not be moved by the grow
  20331. zone function, or NIL if there is no such block. Your grow zone function must be sure
  20332. to call GZSaveHnd; if a handle is returned, it must ensure that this block is not
  20333. moved.
  20334.  
  20335. Assembly-language note:  You can find the same handle in the global
  20336.                          variable GZRootHnd.
  20337.  
  20338. æKY HandleZone
  20339. æFp Memory.p
  20340. æT FUNCTION
  20341. æTN $A126
  20342. æD FUNCTION HandleZone(h: Handle): THz;
  20343. æDT myVariable := HandleZone(h);
  20344. æRI HandleZone function II-34
  20345. æC 
  20346. Trap macro  _HandleZone
  20347. On entry    A0:  h (handle)
  20348. On exit     A0:  function result (pointer)
  20349.             D0:  result code (word)
  20350.  
  20351. HandleZone returns a pointer to the heap zone containing the relocatable block whose
  20352. handle is h. In case of an error, the result returned by HandleZone is undefined and
  20353. should be ignored.
  20354.  
  20355. Warning:  If handle h is empty (points to a NIL master pointer), HandleZone
  20356.           returns a pointer to the current heap zone.
  20357.  
  20358. Result codes    noErr       No error
  20359.                 memWZErr    Attempt to operate on a free block
  20360.  
  20361. æKY HClrRBit
  20362. æFp Memory.p
  20363. æT PROCEDURE
  20364. æTN $A068
  20365. æD PROCEDURE HClrRBit(h: Handle);
  20366. æDT HClrRBit(h);
  20367. æRT 2
  20368. æRI HClrRBit procedure  IV-79, N2-3
  20369. æC 
  20370. Trap macro  _HClrRBit
  20371. On entry    A0:  h (handle)
  20372. On exit     D0:  result code (word)
  20373.  
  20374. HClrRBit clears the resource flag of a relocatable block’s master pointer.
  20375.  
  20376. æKY HGetState
  20377. æFp Memory.p
  20378. æT FUNCTION
  20379. æTN $A069
  20380. æD FUNCTION HGetState(h: Handle): SignedByte;
  20381. æDT myVariable := HGetState(h);
  20382. æRT 2
  20383. æRI HGetState function  IV-79, N2-3
  20384. æC 
  20385. Trap macro  _HGetState
  20386. On entry    A0:  h (handle)
  20387. On exit     D0:  flags (byte)
  20388.  
  20389. HGetState returns the byte that contains the flags of the master pointer for the
  20390. given handle; it’s used in conjunction with HSetState to save and restore the state
  20391. of the flags contained in this byte. You can save this byte, change the state of any
  20392. of the flags (using the routines described above), and then restore their original
  20393. state by passing the byte back to the HSetState procedure (described below).
  20394.  
  20395. æKY HLock
  20396. æFp Memory.p
  20397. æT PROCEDURE
  20398. æTN $A029
  20399. æD PROCEDURE HLock(h: Handle);
  20400. æDT HLock(h);
  20401. æRT 2
  20402. æRI HLock procedure II-41, N2-3
  20403. æC 
  20404. The master pointer associated with each handle contains flags for use by the Memory
  20405. Manager. Routines are provided for setting and clearing each of these flags, as well
  20406. as for saving and restoring the entire byte.
  20407.  
  20408. Warning:  Failure to use these routines virtually guarantees incompatibility
  20409.           with future versions of the Macintosh. You should not set and clear
  20410.           these flags directly.
  20411.  
  20412. The HLock and HUnlock procedures lock and unlock a given relocatable block by setting
  20413. and clearing the lock flag. The HPurge and HNoPurge mark a given relocatable block as
  20414. purgeable or unpurgeable by setting and clearing the purge flag.
  20415.  
  20416. A third flag, the resource flag, is used internally by the Resource Manager. The
  20417. HSetRBit and HClrRBit procedures set and clear this flag.
  20418. The HSetState and HGetState routines let you save and restore the state of the flags
  20419. byte.
  20420.  
  20421. PROCEDURE HLock (h:  Handle);
  20422.  
  20423. Trap macro  _HLock
  20424. On entry    A0:  h (handle)
  20425. On exit     D0:  result code (word)
  20426.  
  20427. HLock locks a relocatable block, preventing it from being moved within its heap zone.
  20428. If the block is already locked, HLock does nothing.
  20429.  
  20430. Warning:  To prevent heap fragmentation, you should always call MoveHHi
  20431.           before locking a relocatable block.
  20432.  
  20433. Result codes    noErr           No error
  20434.                 nilHandleErr    NIL master pointer
  20435.                 memWZErr        Attempt to operate on a free block
  20436.  
  20437. æKY HNoPurge
  20438. æFp Memory.p
  20439. æT PROCEDURE
  20440. æTN $A04A
  20441. æD PROCEDURE HNoPurge(h: Handle);
  20442. æDT HNoPurge(h);
  20443. æRT 2
  20444. æRI HNoPurge procedure II-42, N2-3
  20445. æC 
  20446. Trap macro  _HNoPurge
  20447. On entry    A0:  h (handle)
  20448. On exit     D0:  result code (word)
  20449.  
  20450. HNoPurge marks a relocatable block as unpurgeable. If the block is already unpurgeable,
  20451. HNoPurge does nothing.
  20452.  
  20453. Result codes    noErr           No error
  20454.                 nilHandleErr    NIL master pointer
  20455.                 memWZErr        Attempt to operate on a free block
  20456.  
  20457. æKY HPurge
  20458. æFp Memory.p
  20459. æT PROCEDURE
  20460. æTN $A049
  20461. æD PROCEDURE HPurge(h: Handle);
  20462. æDT HPurge(h);
  20463. æRT 2
  20464. æRI HPurge procedure II-41
  20465. æC 
  20466. Trap macro  _HPurge
  20467. On entry    A0:  h (handle)
  20468. On exit     D0:  result code (word)
  20469.  
  20470. HPurge marks a relocatable block as purgeable. If the block is already purgeable,
  20471. HPurge does nothing.
  20472.  
  20473. Note:  If you call HPurge on a locked block, it won’t unlock the block, but
  20474.        it will mark the block as purgeable. If you later call HUnlock, the
  20475.        block will be subject to purging.
  20476.  
  20477. Result codes    noErr           No error
  20478.                 nilHandleErr    NIL master pointer
  20479.                 memWZErr        Attempt to operate on a free block
  20480.  
  20481. æKY HSetRBit
  20482. æFp Memory.p
  20483. æT PROCEDURE
  20484. æTN $A067
  20485. æD PROCEDURE HSetRBit(h: Handle);
  20486. æDT HSetRBit(h);
  20487. æRT 2
  20488. æRI HSetRBit procedure  IV-79, N2-3
  20489. æC 
  20490. Trap macro  _HSetRBit
  20491. On entry    A0:  h (handle)
  20492. On exit     D0:  result code (word)
  20493.  
  20494. HSetRBit sets the resource flag of a relocatable block’s master pointer.
  20495.  
  20496. æKY HSetState
  20497. æFp Memory.p
  20498. æT PROCEDURE
  20499. æTN $A06A
  20500. æD PROCEDURE HSetState(h: Handle;flags: SignedByte);
  20501. æDT HSetState(h,flags);
  20502. æRT 2
  20503. æRI HSetState procedure  IV-80, N2-3
  20504. æC 
  20505. Trap macro  _HSetState
  20506. On entry    A0:  h (handle)
  20507.             D0:  flags (byte)
  20508. On exit     D0:  result code (word)
  20509.  
  20510. HSetState is used in conjunction with HGetState; it sets the byte that contains the
  20511. flags of the master pointer for the given handle to the byte specified by flags.
  20512.  
  20513. æKY HUnlock
  20514. æFp Memory.p
  20515. æT PROCEDURE
  20516. æTN $A02A
  20517. æD PROCEDURE HUnlock(h: Handle);
  20518. æDT HUnlock(h);
  20519. æRT 2
  20520. æRI HUnlock procedure II-41, N2-3
  20521. æC 
  20522. The master pointer associated with each handle contains flags for use by the Memory
  20523. Manager. Routines are provided for setting and clearing each of these flags, as well
  20524. as for saving and restoring the entire byte.
  20525.  
  20526. Warning:  Failure to use these routines virtually guarantees incompatibility
  20527.           with future versions of the Macintosh. You should not set and clear
  20528.           these flags directly.
  20529.  
  20530. The HLock and HUnlock procedures lock and unlock a given relocatable block by setting
  20531. and clearing the lock flag. The HPurge and HNoPurge mark a given relocatable block as
  20532. purgeable or unpurgeable by setting and clearing the purge flag.
  20533.  
  20534. A third flag, the resource flag, is used internally by the Resource Manager. The
  20535. HSetRBit and HClrRBit procedures set and clear this flag.
  20536. The HSetState and HGetState routines let you save and restore the state of the flags
  20537. byte.
  20538.  
  20539. PROCEDURE HUnlock (h:  Handle);
  20540.  
  20541. Trap macro  _HUnlock
  20542. On entry    A0:  h (handle)
  20543. On exit     D0:  result code (word)
  20544.  
  20545. HUnlock unlocks a relocatable block, allowing it to be moved within its heap zone. If
  20546. the block is already unlocked, HUnlock does nothing.
  20547.  
  20548. Result codes    noErr           No error
  20549.                 nilHandleErr    NIL master pointer
  20550.                 memWZErr        Attempt to operate on a free block
  20551.  
  20552. æKY InitApplZone
  20553. æFp Memory.p
  20554. æT PROCEDURE
  20555. æTN $A02C
  20556. æD PROCEDURE InitApplZone;
  20557. æDT InitApplZone;
  20558. æMM   
  20559. æRI InitApplZone procedure II-28, N64-2
  20560. æC 
  20561. Trap macro   _InitApplZone
  20562. On exit      D0:  result code (word)
  20563.  
  20564. InitApplZone initializes the application heap zone and makes it the current zone. The
  20565. contents of any previous application zone are lost; all previously existing blocks in
  20566. that zone are discarded. The zone’s grow zone function is set to NIL. InitApplZone is
  20567. called by the Segment Loader when starting up an application; you shouldn’t normally
  20568. need to call it.
  20569.  
  20570. Warning:  Reinitializing the application zone from within a running program
  20571.           is tricky, since the program’s code itself normally resides in the
  20572.           application zone. To do it safely, the code containing the
  20573.           InitApplZone call cannot be in the application zone.
  20574.  
  20575. Result codes    noErr    No error
  20576.  
  20577. æKY InitZone
  20578. æFp Memory.p
  20579. æT PROCEDURE
  20580. æTN $A019
  20581. æD PROCEDURE InitZone(pgrowZone: ProcPtr;cmoreMasters: INTEGER;limitPtr: Ptr;
  20582.     startPtr: Ptr);
  20583. æDT InitZone(pgrowZone,cmoreMasters,limitPtr,startPtr);
  20584. æMM   
  20585. æRI InitZone procedure II-29
  20586. æC 
  20587. Trap macro  _InitZone
  20588. On entry    A0:    pointer to parameter block
  20589.  
  20590. Parameter block
  20591.     0    startPtr      pointer
  20592.     4    limitPtr      pointer
  20593.     8    cMoreMasters  word
  20594.     10   pGrowZone     pointer
  20595.  
  20596. On exit     D0:    result code (word)
  20597.  
  20598. InitZone creates a new heap zone, initializes its header and trailer, and makes it
  20599. the current zone. The startPtr parameter is a pointer to the first byte of the new
  20600. zone; limitPtr points to the first byte beyond the end of the zone. The new zone will
  20601. occupy memory addresses from ORD(startPtr) through
  20602. ORD(limitPtr)–1.
  20603.  
  20604. CMoreMasters tells how many master pointers should be allocated at a time for the new
  20605. zone. This number of master pointers are created initially; should more be needed
  20606. later, they’ll be added in increments of this same number.
  20607.  
  20608. The pGrowZone parameter is a pointer to the grow zone function for the new zone, if
  20609. any. If you’re not defining a grow zone function for this zone, pass NIL.
  20610.  
  20611. The new zone includes a 52-byte header and a 12-byte trailer, so its actual usable
  20612. space runs from ORD(startPtr)+52 through ORD(limitPtr)–13. In addition, there’s an
  20613. eight-byte header for the master pointer block, as well as four bytes for each master
  20614. pointer, within this usable area. Thus the total available space in the zone, in
  20615. bytes, is initially
  20616.  
  20617.   ORD(limitPtr) – ORD(startPtr) – 64 – (8 + (4*cMoreMasters))
  20618.  
  20619. This number must not be less than 0. Note that the amount of available space in the
  20620. zone will decrease as more master pointers are allocated.
  20621.  
  20622. Result codes    noErr    No error
  20623.  
  20624. æKY MaxApplZone
  20625. æFp Memory.p
  20626. æT PROCEDURE
  20627. æTN $A063
  20628. æD PROCEDURE MaxApplZone;
  20629. æDT MaxApplZone;
  20630. æRT 103
  20631. æRI MaxApplZone procedure  II-30, IV-77, 83, N39-1, N103
  20632. æC 
  20633. Trap macro  _MaxApplZone
  20634. On exit     D0:  result code (word)
  20635.  
  20636. MaxApplZone expands the application heap zone to the application heap limit without
  20637. purging any blocks currently in the zone. If the zone already extends to the limit,
  20638. it won’t be changed.
  20639.  
  20640. Assembly-language note:  To expand the application heap zone to the
  20641.                          application heap limit from assembly language,
  20642.                          call this Pascal procedure from your program.
  20643.  
  20644. Result codes    noErr    No error
  20645.  
  20646. æKY MaxBlock
  20647. æFp Memory.p
  20648. æT FUNCTION
  20649. æTN $A061
  20650. æD FUNCTION MaxBlock: LONGINT;
  20651. æDT myVariable := MaxBlock;
  20652. æRI MaxBlock function  IV-77
  20653. æC 
  20654. Trap macro  _MaxBlock
  20655.             _MaxBlock ,SYS    (applies to system heap)
  20656. On exit     D0:  function result (word)
  20657.  
  20658. MaxBlock returns the maximum contiguous space in bytes that could be obtained by
  20659. compacting the current zone (without actually doing the compaction).
  20660.  
  20661. æKY MaxMem
  20662. æFp Memory.p
  20663. æT FUNCTION
  20664. æTN $A11D
  20665. æD FUNCTION MaxMem(VAR grow: Size): Size;
  20666. æDT myVariable := MaxMem(grow);
  20667. æRI MaxMem function  II-38
  20668. æC 
  20669. Trap macro  _MaxMem
  20670.             _MaxMem ,SYS (applies to system heap)
  20671. On exit     D0:  function result (long word)
  20672.             A0:  grow (long word)
  20673.  
  20674. MaxMem compacts the current heap zone and purges all purgeable blocks from the zone.
  20675. It returns as its result the size in bytes of the largest contiguous free block in
  20676. the zone after the compaction. If the current zone is the original application heap
  20677. zone, the grow parameter is set to the maximum number of bytes by which the zone can
  20678. grow. For any other heap zone, grow is set to 0. MaxMem doesn’t actually expand the
  20679. zone or call its grow zone function.
  20680.  
  20681. Result codes    noErr    No error [Pascal only]
  20682.  
  20683. æKY maxSize
  20684. æFp Memory.p
  20685. æC maxSize = $800000; {Max data block size is 8 megabytes}
  20686.  
  20687. æKY MemError
  20688. æFp Memory.p
  20689. æT FUNCTION
  20690. æD FUNCTION MemError: OSErr;
  20691. æDT myVariable := MemError;
  20692. æRT 7
  20693. æRI MemError function  II-44, N7-2
  20694. æC  
  20695. All Memory Manager routines (including the RecoverHandle function) return a result
  20696. code that you can examine by calling the MemError function.
  20697.  
  20698. Assembly-language note:  The trap _RecoverHandle doesn’t return a result code
  20699.                          in register D0. The result code of the most recent
  20700.                          call, however, is always stored in the global
  20701.                          variable MemErr.
  20702.  
  20703. FUNCTION MemError :  OSErr; [Not in ROM]
  20704.  
  20705. MemError returns the result code produced by the last Memory Manager routine called
  20706. directly by your program. (OSErr is an Operating System Utility data type declared as
  20707. INTEGER.)
  20708.  
  20709. Assemby-language note:  To get a routine’s result code from assembly language,
  20710.                         look in register D0 on return from the routine (except
  20711.                         for certain routines as noted).
  20712.  
  20713. æKY MFFreeMem
  20714. æFp Memory.p
  20715. æT FUNCTION
  20716. æTN $A88F
  20717. æD FUNCTION MFFreeMem: LONGINT;
  20718. æDT myVariable := MFFreeMem;
  20719.  
  20720. æKY MFMaxMem
  20721. æFp Memory.p
  20722. æT FUNCTION
  20723. æTN $A88F
  20724. æD FUNCTION MFMaxMem(VAR grow: Size): Size;
  20725. æDT myVariable := MFMaxMem(grow);
  20726.  
  20727. æKY MFTempDisposHandle
  20728. æFp Memory.p
  20729. æT PROCEDURE
  20730. æTN $A88F
  20731. æD PROCEDURE MFTempDisposHandle(h: Handle;VAR resultCode: OSErr);
  20732. æDT MFTempDisposHandle(h,resultCode);
  20733.  
  20734. æKY MFTempHLock
  20735. æFp Memory.p
  20736. æT PROCEDURE
  20737. æTN $A88F
  20738. æD PROCEDURE MFTempHLock(h: Handle;VAR resultCode: OSErr);
  20739. æDT MFTempHLock(h,resultCode);
  20740.  
  20741. æKY MFTempHUnlock
  20742. æFp Memory.p
  20743. æT PROCEDURE
  20744. æTN $A88F
  20745. æD PROCEDURE MFTempHUnlock(h: Handle;VAR resultCode: OSErr);
  20746. æDT MFTempHUnlock(h,resultCode);
  20747.  
  20748. æKY MFTempNewHandle
  20749. æFp Memory.p
  20750. æT FUNCTION
  20751. æTN $A88F
  20752. æD FUNCTION MFTempNewHandle(logicalSize: Size;VAR resultCode: OSErr): Handle;
  20753. æDT myVariable := MFTempNewHandle(logicalSize,resultCode);
  20754. æRT 205
  20755.  
  20756.  
  20757. æKY MFTopMem
  20758. æFp Memory.p
  20759. æT FUNCTION
  20760. æTN $A88F
  20761. æD FUNCTION MFTopMem: Ptr;
  20762. æDT myVariable := MFTopMem;
  20763.  
  20764. æKY MoreMasters
  20765. æFp Memory.p
  20766. æT PROCEDURE
  20767. æTN $A036
  20768. æD PROCEDURE MoreMasters;
  20769. æDT MoreMasters;
  20770. æMM 
  20771. æRT 53
  20772. æRI MoreMasters procedure  II-31, N53
  20773. æC 
  20774. Trap macro  _MoreMasters
  20775.  
  20776. MoreMasters allocates another block of master pointers in the current heap zone. This
  20777. procedure is usually called very early in an application.
  20778.  
  20779. Result codes    noErr         No error
  20780.                 memFullErr    Not enough room in heap zone
  20781.  
  20782. æKY MoveHHi
  20783. æFp Memory.p
  20784. æT PROCEDURE
  20785. æTN $A064
  20786. æD PROCEDURE MoveHHi(h: Handle);
  20787. æDT MoveHHi(h);
  20788. æMM 
  20789. æRT 103, 111
  20790. æRI MoveHHi procedure  II-44, IV-77, 83, N103, N111
  20791. æC 
  20792. [Not in 64K ROM]
  20793.  
  20794. Trap macro  _MoveHHi
  20795. On entry    A0:  h (handle)
  20796. On exit     D0:  result code (word)
  20797.  
  20798. MoveHHi moves the relocatable block whose handle is h toward the top of the current
  20799. heap zone, until the block hits either a nonrelocatable block, a locked relocatable
  20800. block, or the last block in the current heap zone. By calling MoveHHi before you lock
  20801. a relocatable block, you can avoid fragmentation of the heap, as well as make room
  20802. for future pointers as low in the heap as possible.
  20803.  
  20804. Result codes    noErr           No error
  20805.                 nilHandleErr    NIL master pointer
  20806.                 memLockedErr    Block is locked
  20807.  
  20808. æKY NewEmptyHandle
  20809. æFp Memory.p
  20810. æT FUNCTION
  20811. æTN $A066
  20812. æD FUNCTION NewEmptyHandle: Handle;
  20813. æDT myVariable := NewEmptyHandle;
  20814. æMM   
  20815. æRI NewEmptyHandle function  IV-78
  20816. æC 
  20817. Trap macro  _NewEmptyHandle
  20818.             _NewEmptyHandle ,SYS    (applies to system heap)
  20819. On exit     A0:  function result (handle)
  20820.             D0:  result code (word)
  20821.  
  20822. NewEmptyHandle is similar in function to NewHandle except that it does not allocate
  20823. any space; the handle returned is empty (in other words, it points to a NIL master
  20824. pointer). NewEmptyHandle is used extensively by the Resource Manager; you may not
  20825. need to use it.
  20826.  
  20827. æKY NewHandle
  20828. æFp Memory.p
  20829. æT FUNCTION
  20830. æTN $A122
  20831. æD FUNCTION NewHandle(byteCount: Size): Handle;
  20832. æDT myVariable := NewHandle(byteCount);
  20833. æMM 
  20834. æRT 7, 117, 205
  20835. æRI NewHandle function  I-76, 80, II-32, N7-2, N117-17, P-51, 177
  20836. æC 
  20837. Trap macro  _NewHandle
  20838.             _NewHandle ,SYS        (applies to system heap)
  20839.             _NewHandle ,CLEAR      (clears allocated block)
  20840.             _NewHandle ,SYS,CLEAR  (applies to system heap and clears
  20841.                                     allocated block)
  20842. On entry    D0:  logicalSize (long word)
  20843. On exit     A0:  function result (handle)
  20844.             D0:  result code (word)
  20845.  
  20846. NewHandle attempts to allocate a new relocatable block of logicalSize bytes from the
  20847. current heap zone and then return a handle to it. The new block will be unlocked and
  20848. unpurgeable. If logicalSize bytes can’t be allocated, NewHandle returns NIL.
  20849.  
  20850. NewHandle will pursue all available avenues to create a free block of the requested
  20851. size, including compacting the heap zone, increasing its size, purging blocks from
  20852. it, and calling its grow zone function, if any.
  20853.  
  20854. Result codes    noErr         No error
  20855.                 memFullErr    Not enough room in heap zone
  20856.  
  20857. æKY NewHandleClear
  20858. æFp Memory.p
  20859. æT FUNCTION
  20860. æTN $A122
  20861. æD FUNCTION NewHandleClear(byteCount: Size): Handle;
  20862. æDT myVariable := NewHandleClear(byteCount);
  20863. æRT 219
  20864. æC 
  20865. Trap macro  _NewHandle
  20866.             _NewHandle ,SYS        (applies to system heap)
  20867.             _NewHandle ,CLEAR      (clears allocated block)
  20868.             _NewHandle ,SYS,CLEAR  (applies to system heap and clears
  20869.                                     allocated block)
  20870. On entry    D0:  logicalSize (long word)
  20871. On exit     A0:  function result (handle)
  20872.             D0:  result code (word)
  20873.  
  20874. NewHandle attempts to allocate a new relocatable block of logicalSize bytes from the
  20875. current heap zone and then return a handle to it. The new block will be unlocked and
  20876. unpurgeable. If logicalSize bytes can’t be allocated, NewHandle returns NIL.
  20877.  
  20878. NewHandle will pursue all available avenues to create a free block of the requested
  20879. size, including compacting the heap zone, increasing its size, purging blocks from
  20880. it, and calling its grow zone function, if any.
  20881.  
  20882. Result codes    noErr         No error
  20883.                 memFullErr    Not enough room in heap zone
  20884.  
  20885.  
  20886. æKY NewHandleSys
  20887. æFp Memory.p
  20888. æT FUNCTION
  20889. æTN $A122
  20890. æD FUNCTION NewHandleSys(byteCount: Size): Handle;
  20891. æDT myVariable := NewHandleSys(byteCount);
  20892. æRT 219
  20893. æC 
  20894. Trap macro  _NewHandle
  20895.             _NewHandle ,SYS        (applies to system heap)
  20896.             _NewHandle ,CLEAR      (clears allocated block)
  20897.             _NewHandle ,SYS,CLEAR  (applies to system heap and clears
  20898.                                     allocated block)
  20899. On entry    D0:  logicalSize (long word)
  20900. On exit     A0:  function result (handle)
  20901.             D0:  result code (word)
  20902.  
  20903. NewHandle attempts to allocate a new relocatable block of logicalSize bytes from the
  20904. current heap zone and then return a handle to it. The new block will be unlocked and
  20905. unpurgeable. If logicalSize bytes can’t be allocated, NewHandle returns NIL.
  20906.  
  20907. NewHandle will pursue all available avenues to create a free block of the requested
  20908. size, including compacting the heap zone, increasing its size, purging blocks from
  20909. it, and calling its grow zone function, if any.
  20910.  
  20911. Result codes    noErr         No error
  20912.                 memFullErr    Not enough room in heap zone
  20913.  
  20914.  
  20915. æKY NewHandleSysClear
  20916. æFp Memory.p
  20917. æT FUNCTION
  20918. æTN $A122
  20919. æD FUNCTION NewHandleSysClear(byteCount: Size): Handle;
  20920. æDT myVariable := NewHandleSysClear(byteCount);
  20921. æRT 219
  20922. æC 
  20923. Trap macro  _NewHandle
  20924.             _NewHandle ,SYS        (applies to system heap)
  20925.             _NewHandle ,CLEAR      (clears allocated block)
  20926.             _NewHandle ,SYS,CLEAR  (applies to system heap and clears
  20927.                                     allocated block)
  20928. On entry    D0:  logicalSize (long word)
  20929. On exit     A0:  function result (handle)
  20930.             D0:  result code (word)
  20931.  
  20932. NewHandle attempts to allocate a new relocatable block of logicalSize bytes from the
  20933. current heap zone and then return a handle to it. The new block will be unlocked and
  20934. unpurgeable. If logicalSize bytes can’t be allocated, NewHandle returns NIL.
  20935.  
  20936. NewHandle will pursue all available avenues to create a free block of the requested
  20937. size, including compacting the heap zone, increasing its size, purging blocks from
  20938. it, and calling its grow zone function, if any.
  20939.  
  20940. Result codes    noErr         No error
  20941.                 memFullErr    Not enough room in heap zone
  20942.  
  20943.  
  20944. æKY NewPtr
  20945. æFp Memory.p
  20946. æT FUNCTION
  20947. æTN $A11E
  20948. æD FUNCTION NewPtr(byteCount: Size): Ptr;
  20949. æDT myVariable := NewPtr(byteCount);
  20950. æMM   
  20951. æRI NewPtr function  I-75, 79, II-36, P-51, 177
  20952. æC 
  20953. Trap macro  _NewPtr
  20954.             _NewPtr ,SYS        (applies to system heap)
  20955.             _NewPtr ,CLEAR      (clears allocated block)
  20956.             _NewPtr ,SYS,CLEAR  (applies to system heap and clears
  20957.                                  allocated block)
  20958. On entry    D0:  logicalSize (long word)
  20959. On exit     A0:  function result (pointer)
  20960.             D0:  result code (word)
  20961.  
  20962. NewPtr attempts to allocate a new nonrelocatable block of logicalSize bytes from the
  20963. current heap zone and then return a pointer to it. If logicalSize bytes can’t be
  20964. allocated, NewPtr returns NIL.
  20965.  
  20966. NewPtr will pursue all available avenues to create a free block of the requested size
  20967. at the lowest possible location in the heap zone, including compacting the heap zone,
  20968. increasing its size, purging blocks from it, and calling its grow zone function, if
  20969. any.
  20970.  
  20971. Result codes    noErr         No error
  20972.                 memFullErr    Not enough room in heap zone
  20973.  
  20974. æKY NewPtrClear
  20975. æFp Memory.p
  20976. æT FUNCTION
  20977. æTN $A11E
  20978. æD FUNCTION NewPtrClear(byteCount: Size): Ptr;
  20979. æDT myVariable := NewPtrClear(byteCount);
  20980. æRT 219
  20981. æC 
  20982. Trap macro  _NewPtr
  20983.             _NewPtr ,SYS        (applies to system heap)
  20984.             _NewPtr ,CLEAR      (clears allocated block)
  20985.             _NewPtr ,SYS,CLEAR  (applies to system heap and clears
  20986.                                  allocated block)
  20987. On entry    D0:  logicalSize (long word)
  20988. On exit     A0:  function result (pointer)
  20989.             D0:  result code (word)
  20990.  
  20991. NewPtr attempts to allocate a new nonrelocatable block of logicalSize bytes from the
  20992. current heap zone and then return a pointer to it. If logicalSize bytes can’t be
  20993. allocated, NewPtr returns NIL.
  20994.  
  20995. NewPtr will pursue all available avenues to create a free block of the requested size
  20996. at the lowest possible location in the heap zone, including compacting the heap zone,
  20997. increasing its size, purging blocks from it, and calling its grow zone function, if
  20998. any.
  20999.  
  21000. Result codes    noErr         No error
  21001.                 memFullErr    Not enough room in heap zone
  21002.  
  21003. æKY NewPtrSys
  21004. æFp Memory.p
  21005. æT FUNCTION
  21006. æTN $A11E
  21007. æD FUNCTION NewPtrSys(byteCount: Size): Ptr;
  21008. æDT myVariable := NewPtrSys(byteCount);
  21009. æRT 219
  21010. æC 
  21011. Trap macro  _NewPtr
  21012.             _NewPtr ,SYS        (applies to system heap)
  21013.             _NewPtr ,CLEAR      (clears allocated block)
  21014.             _NewPtr ,SYS,CLEAR  (applies to system heap and clears
  21015.                                  allocated block)
  21016. On entry    D0:  logicalSize (long word)
  21017. On exit     A0:  function result (pointer)
  21018.             D0:  result code (word)
  21019.  
  21020. NewPtr attempts to allocate a new nonrelocatable block of logicalSize bytes from the
  21021. current heap zone and then return a pointer to it. If logicalSize bytes can’t be
  21022. allocated, NewPtr returns NIL.
  21023.  
  21024. NewPtr will pursue all available avenues to create a free block of the requested size
  21025. at the lowest possible location in the heap zone, including compacting the heap zone,
  21026. increasing its size, purging blocks from it, and calling its grow zone function, if
  21027. any.
  21028.  
  21029. Result codes    noErr         No error
  21030.                 memFullErr    Not enough room in heap zone
  21031.  
  21032. æKY NewPtrSysClear
  21033. æFp Memory.p
  21034. æT FUNCTION
  21035. æTN $A11E
  21036. æD FUNCTION NewPtrSysClear(byteCount: Size): Ptr;
  21037. æDT myVariable := NewPtrSysClear(byteCount);
  21038. æRT 219
  21039. æC 
  21040. Trap macro  _NewPtr
  21041.             _NewPtr ,SYS        (applies to system heap)
  21042.             _NewPtr ,CLEAR      (clears allocated block)
  21043.             _NewPtr ,SYS,CLEAR  (applies to system heap and clears
  21044.                                  allocated block)
  21045. On entry    D0:  logicalSize (long word)
  21046. On exit     A0:  function result (pointer)
  21047.             D0:  result code (word)
  21048.  
  21049. NewPtr attempts to allocate a new nonrelocatable block of logicalSize bytes from the
  21050. current heap zone and then return a pointer to it. If logicalSize bytes can’t be
  21051. allocated, NewPtr returns NIL.
  21052.  
  21053. NewPtr will pursue all available avenues to create a free block of the requested size
  21054. at the lowest possible location in the heap zone, including compacting the heap zone,
  21055. increasing its size, purging blocks from it, and calling its grow zone function, if
  21056. any.
  21057.  
  21058. Result codes    noErr         No error
  21059.                 memFullErr    Not enough room in heap zone
  21060.  
  21061. æKY PtrZone
  21062. æFp Memory.p
  21063. æT FUNCTION
  21064. æTN $A148
  21065. æD FUNCTION PtrZone(p: Ptr): THz;
  21066. æDT myVariable := PtrZone(p);
  21067. æRI PtrZone function II-38
  21068. æC 
  21069. Trap macro  _PtrZone
  21070. On entry    A0:  p (pointer)
  21071. On exit     A0:  function result (pointer)
  21072.             D0:  result code (word)
  21073.  
  21074. PtrZone returns a pointer to the heap zone containing the nonrelocatable block pointed
  21075. to by p. In case of an error, the result returned by PtrZone is undefined and should
  21076. be ignored.
  21077.  
  21078. Result codes    noErr       No error
  21079.                 memWZErr    Attempt to operate on a free block
  21080.  
  21081. æKY PurgeMem
  21082. æFp Memory.p
  21083. æT PROCEDURE
  21084. æTN $A04D
  21085. æD PROCEDURE PurgeMem(cbNeeded: Size);
  21086. æDT PurgeMem(cbNeeded);
  21087. æMM 
  21088. æRT 51
  21089. æRI PurgeMem procedure II-40, N51-1
  21090. æC 
  21091. Trap macro  _PurgeMem
  21092.             _PurgeMem ,SYS (applies to system heap)
  21093. On entry    D0:  cbNeeded (long word)
  21094. On exit     D0:  result code (word)
  21095.  
  21096. PurgeMem sequentially purges blocks from the current heap zone until a contiguous
  21097. block of at least cbNeeded free bytes is created or the entire zone is purged; it
  21098. doesn’t compact the heap zone. Only relocatable, unlocked, purgeable blocks can be
  21099. purged. Note that PurgeMem doesn’t actually allocate the block.
  21100.  
  21101. Result codes    noErr         No error
  21102.                 memFullErr    Not enough room in heap zone
  21103.  
  21104. æKY PurgeSpace
  21105. æFp Memory.p
  21106. æT PROCEDURE
  21107. æTN $A062
  21108. æD PROCEDURE PurgeSpace(VAR total: LONGINT;VAR contig: LONGINT);
  21109. æDT PurgeSpace(total,contig);
  21110. æRI PurgeSpace procedure  IV-78
  21111. æC 
  21112. Trap macro  _PurgeSpace
  21113.             _PurgeSpace ,SYS    (applies to system heap)
  21114. On exit     A0:  contig (long word)
  21115.             D0:  total (long word)
  21116.  
  21117. PurgeSpace returns in total the total amount of space in bytes that could be obtained
  21118. by a general purge (without actually doing the purge); this amount includes space
  21119. that is already free. The maximum contiguous space in bytes
  21120. (including already free space) that could be obtained by a purge is returned in
  21121. contig.
  21122.  
  21123. æKY ReallocHandle
  21124. æFp Memory.p
  21125. æT PROCEDURE
  21126. æTN $A027
  21127. æD PROCEDURE ReallocHandle(h: Handle;byteCount: Size);
  21128. æDT ReallocHandle(h,byteCount);
  21129. æMM   
  21130. æRI ReallocHandle procedure II-35
  21131. æC 
  21132. Trap macro  _ReallocHandle
  21133. On entry    A0:  h (handle)
  21134.             D0:  logicalSize (long word)
  21135. On exit     D0:  result code (word)
  21136.  
  21137. ReallocHandle allocates a new relocatable block with a logical size of logicalSize
  21138. bytes. It then updates handle h by setting its master pointer to point to the new
  21139. block. The main use of this procedure is to reallocate space for a block that has
  21140. been purged. Normally h is an empty handle, but it need not be:  If it points to an
  21141. existing block, that block is released before the new block is created.
  21142.  
  21143. In case of an error, no new block is allocated and handle h is left unchanged.
  21144.  
  21145. Result codes    noErr         No error
  21146.                 memFullErr    Not enough room in heap zone
  21147.                 memWZErr      Attempt to operate on a free block
  21148.                 memPurErr     Attempt to purge a locked block
  21149.  
  21150. æKY RecoverHandle
  21151. æFp Memory.p
  21152. æT FUNCTION
  21153. æTN $A128
  21154. æD FUNCTION RecoverHandle(p: Ptr): Handle;
  21155. æDT myVariable := RecoverHandle(p);
  21156. æMM 
  21157. æRT 23
  21158. æRI RecoverHandle function II-35, N8-1, N23-1
  21159. æC 
  21160. Trap macro  _RecoverHandle
  21161.             _RecoverHandle ,SYS  (applies to system heap)
  21162. On entry    A0:  p (pointer)
  21163. On exit     A0:  function result (handle)
  21164.             D0:  unchanged
  21165.  
  21166. RecoverHandle returns a handle to the relocatable block pointed to by p.
  21167.  
  21168. Assembly-language note:  The trap _RecoverHandle doesn’t return a result
  21169.                          code in register D0; the previous contents of D0
  21170.                          are preserved unchanged.
  21171.  
  21172. Result codes    noErr    No error [Pascal only]
  21173.  
  21174. æKY ResrvMem
  21175. æFp Memory.p
  21176. æT PROCEDURE
  21177. æTN $A040
  21178. æD PROCEDURE ResrvMem(cbNeeded: Size);
  21179. æDT ResrvMem(cbNeeded);
  21180. æMM   
  21181. æRI ResrvMem procedure II-39
  21182. æC 
  21183. Trap macro  _ResrvMem
  21184.             _ResrvMem ,SYS (applies to system heap)
  21185. On entry    D0:  cbNeeded (long word)
  21186. On exit     D0:  result code (word)
  21187.  
  21188. ResrvMem creates free space for a block of cbNeeded contiguous bytes at the lowest
  21189. possible position in the current heap zone. It will try every available means to
  21190. place the block as close as possible to the bottom of the zone, including moving
  21191. other blocks upward, expanding the zone, or purging blocks from it. Note that ResrvMem
  21192. doesn’t actually allocate the block.
  21193.  
  21194. Note:  When you allocate a relocatable block that you know will be locked for
  21195.        long periods of time, call ResrvMem first. This reserves space for the
  21196.        block near the bottom of the heap zone, where it will interfere with
  21197.        compaction as little as possible. It isn’t necessary to call ResrvMem
  21198.        for a nonrelocatable block; NewPtr calls it automatically. It’s also
  21199.        called automatically when locked resources are read into memory.
  21200.  
  21201. Result codes    noErr         No error
  21202.                 memFullErr    Not enough room in heap zone
  21203.  
  21204. æKY SetApplBase
  21205. æFp Memory.p
  21206. æT PROCEDURE
  21207. æTN $A057
  21208. æD PROCEDURE SetApplBase(startPtr: Ptr);
  21209. æDT SetApplBase(startPtr);
  21210. æMM   
  21211. æRI SetApplBase procedure II-28
  21212. æC 
  21213. Trap macro  _SetAppBase
  21214. On entry    A0:  startPtr (pointer)
  21215. On exit     D0:  result code (word)
  21216.  
  21217. SetApplBase changes the starting address of the application heap zone to the address
  21218. designated by startPtr, and then calls InitApplZone. SetApplBase is normally called
  21219. only by the system itself; you should never need to call this procedure.
  21220.  
  21221. Since the application heap zone begins immediately following the end of the system
  21222. zone, changing its starting address has the effect of changing the size of the system
  21223. zone. The system zone can be made larger, but never smaller; if startPtr points to an
  21224. address lower than the current end of the system zone,
  21225. it’s ignored and the application zone’s starting address is left unchanged.
  21226.  
  21227. Warning:  Like InitApplZone, SetApplBase is a tricky operation, because the
  21228.           program’s code itself normally resides in the application heap zone.
  21229.           To do it safely, the code containing the SetApplBase call cannot be
  21230.           in the application zone.
  21231.  
  21232. Result codes    noErr    No error
  21233.  
  21234. æKY SetApplLimit
  21235. æFp Memory.p
  21236. æT PROCEDURE
  21237. æTN $A02D
  21238. æD PROCEDURE SetApplLimit(zoneLimit: Ptr);
  21239. æDT SetApplLimit(zoneLimit);
  21240. æRI SetApplLimit procedure II-30
  21241. æC 
  21242. Trap macro  _SetApplLimit
  21243. On entry    A0:  zoneLimit (pointer)
  21244. On exit     D0:  result code (word)
  21245.  
  21246. SetApplLimit sets the application heap limit, beyond which the application heap can’t
  21247. be expanded. The actual expansion isn’t under your program’s control, but is done
  21248. automatically by the Memory Manager when necessary to satisfy allocation requests.
  21249. Only the original application zone can be expanded.
  21250.  
  21251. ZoneLimit is a pointer to a byte in memory beyond which the zone will not be allowed
  21252. to grow. The zone can grow to include the byte preceding zoneLimit in memory, but no
  21253. farther. If the zone already extends beyond the specified limit it won’t be cut back,
  21254. but it will be prevented from growing any more.
  21255.  
  21256. Warning:  Notice that zoneLimit is not a byte count. To limit the application
  21257.           zone to a particular size (say 8K bytes), you have to write something
  21258.           like
  21259.  
  21260.             SetApplLimit(Ptr(ApplicZone)+8192)
  21261.  
  21262. The Memory Manager function ApplicZone is explained below.
  21263.  
  21264. Assembly-language note:  You can just store the new application heap
  21265.                          limit in the global variable ApplLimit.
  21266.  
  21267. Result codes    noErr         No error
  21268.                 memFullErr    Not enough room in heap zone
  21269.  
  21270. æKY SetGrowZone
  21271. æFp Memory.p
  21272. æT PROCEDURE
  21273. æTN $A04B
  21274. æD PROCEDURE SetGrowZone(growZone: ProcPtr);
  21275. æDT SetGrowZone(growZone);
  21276. æRI SetGrowZone procedure II-42
  21277. æC 
  21278. Trap macro  _SetGrowZone
  21279. On entry    A0:  growZone (pointer)
  21280. On exit     D0:  result code (word)
  21281.  
  21282. SetGrowZone sets the current heap zone’s grow zone function as designated by the
  21283. growZone parameter. A NIL parameter value removes any grow zone function the zone may
  21284. previously have had.
  21285.  
  21286. Note:  If your program presses the limits of the available heap space, it’s
  21287.        a good idea to have a grow zone function of some sort. At the very
  21288.        least, the grow zone function should take some graceful action—such
  21289.        as displaying an alert box with the message “Out of memory”—instead
  21290.       of just failing unpredictably.
  21291.  
  21292. If it has failed to create a block of the needed size after compacting the zone,
  21293. increasing its size (in the case of the original application zone), and purging
  21294. blocks from it, the Memory Manager calls the grow zone function as a last resort.
  21295.  
  21296. The grow zone function should be of the form
  21297.  
  21298. FUNCTION MyGrowZone (cbNeeded:  Size) :  LONGINT;
  21299.  
  21300. The cbNeeded parameter gives the physical size of the needed block in bytes, including
  21301. the block header. The grow zone function should attempt to create a free block of at
  21302. least this size. It should return a nonzero number if it’s able to allocate some
  21303. memory, or 0 if it’s not able to allocate any.
  21304.  
  21305. If the grow zone function returns 0, the Memory Manager will give up trying to allocate
  21306. the needed block and will signal failure with the result code memFullErr. Otherwise
  21307. it will compact the heap zone and try again to allocate the block. If still unsuccessful,
  21308. it will continue to call the grow zone function repeatedly, compacting the zone again
  21309. after each call, until it either succeeds in allocating the needed block or receives
  21310. a zero result and gives up.
  21311.  
  21312. The usual way for the grow zone function to free more space is to call EmptyHandle to
  21313. purge blocks that were previously marked unpurgeable. Another possibility is to
  21314. unlock blocks that were previously locked
  21315.  
  21316. Note:  Although just unlocking blocks doesn’t actually free any additional
  21317.        space in the zone, the grow zone function should still return a nonzero
  21318.        result in this case. This signals the Memory Manager to compact the
  21319.        heap and try again to allocate the needed block.
  21320.  
  21321. Warning:  Depending on the circumstances in which the grow zone function is
  21322.           called, there may be a particular block within the heap zone that
  21323.           must not be moved. For this reason, it’s essential that your grow
  21324.           zone function call the function GZSaveHnd (see below).
  21325.  
  21326. Result codes    noErr    No error
  21327.  
  21328. æKY SetHandleSize
  21329. æFp Memory.p
  21330. æT PROCEDURE
  21331. æTN $A024
  21332. æD PROCEDURE SetHandleSize(h: Handle;newSize: Size);
  21333. æDT SetHandleSize(h,newSize);
  21334. æMM   
  21335. æRI SetHandleSize procedure II-34
  21336. æC 
  21337. Trap macro  _SetHandleSize
  21338. On entry    A0:  h (handle)
  21339.             D0:  newSize (long word)
  21340. On exit     D0:  result code (word)
  21341.  
  21342. SetHandleSize changes the logical size of the relocatable block whose handle is h to
  21343. newSize bytes.
  21344.  
  21345. Note:  Be prepared for an attempt to increase the size of a locked block to
  21346.        fail, since there may be a block above it that’s either nonrelocatable
  21347.        or locked.
  21348.  
  21349. Result codes    noErr           No error
  21350.                 memFullErr      Not enough room in heap zone
  21351.                 nilHandleErr    NIL master pointer
  21352.                 memWZErr        Attempt to operate on a free block
  21353.  
  21354. æKY SetPtrSize
  21355. æFp Memory.p
  21356. æT PROCEDURE
  21357. æTN $A020
  21358. æD PROCEDURE SetPtrSize(p: Ptr;newSize: Size);
  21359. æDT SetPtrSize(p,newSize);
  21360. æMM   
  21361. æRI SetPtrSize procedure II-37
  21362. æC 
  21363. Trap macro  _SetPtrSize
  21364. On entry    A0:  p (pointer)
  21365.             D0:  newSize (long word)
  21366. On exit     D0:  result code (word)
  21367.  
  21368. SetPtrSize changes the logical size of the nonrelocatable block pointed to by p to
  21369. newSize bytes.
  21370.  
  21371. Result codes    noErr         No error
  21372.                 memFullErr    Not enough room in heap zone
  21373.                 memWZErr      Attempt to operate on a free block
  21374.  
  21375. æKY SetZone
  21376. æFp Memory.p
  21377. æT PROCEDURE
  21378. æTN $A01B
  21379. æD PROCEDURE SetZone(hz: THz);
  21380. æDT SetZone(hz);
  21381. æRI SetZone procedure II-31, N8-1
  21382. æC 
  21383. Trap macro  _SetZone
  21384. On entry    A0:  hz (pointer)
  21385. On exit     D0:  result code (word)
  21386.  
  21387. SetZone sets the current heap zone to the zone pointed to by hz.
  21388.  
  21389. Assembly-language note:  You can set the current heap zone by storing
  21390.                          a pointer to it in the global variable TheZone.
  21391.  
  21392. Result codes    noErr    No error
  21393.  
  21394. æKY Size
  21395. æFp Memory.p
  21396. æT TYPE
  21397. æC 
  21398. Size = LONGINT;     { size of a block in bytes }
  21399.  
  21400. For specifying the sizes of blocks in the heap, the Memory Manager defines a special
  21401. type called Size:
  21402.  
  21403.   TYPE Size = LONGINT;
  21404.  
  21405. All Memory Manager routines that deal with block sizes expect parameters of type Size
  21406. or return them as results.
  21407.  
  21408. æKY StackSpace
  21409. æFp Memory.p
  21410. æT FUNCTION
  21411. æTN $A065
  21412. æD FUNCTION StackSpace: LONGINT;
  21413. æDT myVariable := StackSpace;
  21414. æRI StackSpace function  IV-78
  21415. æC 
  21416. Trap macro  _StackSpace
  21417. On exit     D0:  function result (word)
  21418.  
  21419. StackSpace returns the current amount of stack space between the current stack pointer
  21420. and the application heap (at the instant of return from the trap).
  21421.  
  21422. æKY StripAddress
  21423. æFp Memory.p
  21424. æT FUNCTION
  21425. æTN $A055
  21426. æD FUNCTION StripAddress(theAddress: Ptr): Ptr;
  21427. æDT myVariable := StripAddress(theAddress);
  21428. æRT 212,213
  21429. æRI StripAddress function  V-593
  21430. æC 
  21431. Trap macro  _StripAddress
  21432. On entry    D0:  theAddress (pointer)
  21433. On exit     D0:  function result (pointer)
  21434.  
  21435. The original description of StripAddress was incorrect.  Technical Note #213 correctly
  21436. documents this function.
  21437.  
  21438. •••Refer to Technical Note #213:•••
  21439.  
  21440. æKY SystemZone
  21441. æFp Memory.p
  21442. æT FUNCTION
  21443. æD FUNCTION SystemZone: THz;
  21444. æDT myVariable := SystemZone;
  21445. æRI SystemZone function II-32
  21446. æC 
  21447. [Not in ROM]
  21448.  
  21449. SystemZone returns a pointer to the system heap zone.
  21450.  
  21451. Assembly-language note:  The global variable SysZone contains
  21452.                          a pointer to the system heap zone.
  21453.  
  21454. æKY TopMem
  21455. æFp Memory.p
  21456. æT FUNCTION
  21457. æD FUNCTION TopMem: Ptr;
  21458. æDT myVariable := TopMem;
  21459. æRI TopMem function II-44
  21460. æC  
  21461. [Not in ROM]
  21462.  
  21463. On a Macintosh 128K or 512K, TopMem returns a pointer to the end of RAM; on the
  21464. Macintosh XL, it returns a pointer to the end of the memory available for use by the
  21465. application.
  21466.  
  21467. Assembly-language note:  This value is stored in the global variable MemTop.
  21468.  
  21469. æKY Menus.p
  21470. æKL AddResMenu
  21471. AppendMenu
  21472. CalcMenuSize
  21473. CheckItem
  21474. ClearMenuBar
  21475. CountMItems
  21476. DeleteMenu
  21477. DelMCEntries
  21478. DelMenuItem
  21479. DisableItem
  21480. DispMCInfo
  21481. DisposeMenu
  21482. DrawMenuBar
  21483. EnableItem
  21484. FlashMenuBar
  21485. GetItem
  21486. GetItemCmd
  21487. GetItemIcon
  21488. GetItemMark
  21489. GetItemStyle
  21490. GetMCEntry
  21491. GetMCInfo
  21492. GetMenu
  21493. GetMenuBar
  21494. GetMHandle
  21495. GetNewMBar
  21496. HiliteMenu
  21497. InitMenus
  21498. InitProcMenu
  21499. InsertMenu
  21500. InsertResMenu
  21501. InsMenuItem
  21502. MenuChoice
  21503. MenuKey
  21504. MenuSelect
  21505. NewMenu
  21506. PopUpMenuSelect
  21507. SetItem
  21508. SetItemCmd
  21509. SetItemIcon
  21510. SetItemMark
  21511. SetItemStyle
  21512. SetMCEntries
  21513. SetMCInfo
  21514. SetMenuBar
  21515. SetMenuFlash
  21516.  
  21517. dsHMenuFindErr
  21518. dsMBarNFnd
  21519. hierMenu
  21520. hMenuCmd
  21521. hPopUpMsg
  21522. MCEntry
  21523. MCEntryPtr
  21524. mChooseMsg
  21525. MCTable
  21526. MCTableHandle
  21527. MCTablePtr
  21528. mctAllItems
  21529. mctLastIDIndic
  21530. mDrawMsg
  21531. MenuHandle
  21532. MenuInfo
  21533. MenuPtr
  21534. mPopUpMsg
  21535. mSizeMsg
  21536. noMark
  21537. textMenuProc
  21538.  
  21539. æKY MenuInfo,MenuPtr,MenuHandle
  21540. æFp Menus.p
  21541. æT TYPE
  21542. æC MenuPtr = ^MenuInfo;
  21543. MenuHandle = ^MenuPtr;
  21544. MenuInfo = RECORD
  21545.    menuID: INTEGER;
  21546.    menuWidth: INTEGER;
  21547.    menuHeight: INTEGER;
  21548.    menuProc: Handle;
  21549.    enableFlags: LONGINT;
  21550.    menuData: Str255;
  21551.    END;
  21552. _______________________________________________________________________________
  21553.  
  21554. »MENU MANAGER DATA STRUCTURES
  21555. _______________________________________________________________________________
  21556.  
  21557. The Menu Manager keeps all the information it needs for its operations on a particular
  21558. menu in a menu record. The menu record contains the following:
  21559.  
  21560.   •  The menu ID, a number that identifies the menu. The menu ID can be the
  21561.      same number as the menu’s resource ID, though it doesn’t have to be.
  21562.   •  The menu title.
  21563.   •  The contents of the menu—the text and other parts of each item.
  21564.   •  The horizontal and vertical dimensions of the menu, in pixels. The menu
  21565.      items appear inside the rectangle formed by these dimensions; the black
  21566.      border and shadow of the menu appear outside that rectangle.
  21567.   •  A handle to the menu definition procedure.
  21568.   •  Flags telling whether each menu item is enabled or disabled, and whether
  21569.      the menu itself is enabled or disabled.
  21570.  
  21571. The data type for a menu record is called MenuInfo. A menu record is referred to by a
  21572. handle:
  21573.  
  21574. TYPE  MenuPtr    = ^MenuInfo;
  21575.       MenuHandle = ^MenuPtr;
  21576.  
  21577. You can store into and access all the necessary fields of a menu record with Menu
  21578. Manager routines, so normally you don’t have to know the exact field names. However,
  21579. if you want more information about the exact structure of a menu record—if you’re
  21580. defining your own menu types, for instance—it’s given below.
  21581.  
  21582. _______________________________________________________________________________
  21583.  
  21584. »The MenuInfo Data Type
  21585.  
  21586. The type MenuInfo is defined as follows:
  21587.  
  21588. TYPE  MenuInfo = RECORD
  21589.                    menuID:       INTEGER;  {menu ID}
  21590.                    menuWidth:    INTEGER;  {menu width in pixels}
  21591.                    menuHeight:   INTEGER;  {menu height in pixels}
  21592.                    menuProc:     Handle;   {menu definition procedure}
  21593.                    enableFlags:  LONGINT;  {tells if menu or items are enabled}
  21594.                    menuData:    Str255     {menu title (and other data)}
  21595.                  END;
  21596.  
  21597. The menuID field contains the menu ID. MenuWidth and menuHeight are the menu’s horizontal
  21598. and vertical dimensions in pixels. MenuProc is a handle to the menu definition procedure
  21599. for this type of menu.
  21600.  
  21601. Bit 0 of the enableFlags field is 1 if the menu is enabled, or 0 if it’s disabled.
  21602. Bits 1 to 31 similarly tell whether each item in the menu is enabled or disabled.
  21603.  
  21604. The menuData field contains the menu title followed by variable-length data that
  21605. defines the text and other parts of the menu items. The Str255 data type enables you
  21606. to access the title from Pascal; there’s actually additional data beyond the title
  21607. that’s inaccessible from Pascal and is not reflected in the MenuInfo data structure.
  21608.  
  21609. Warning:  You can read the menu title directly from the menuData field, but
  21610.           do not change the title directly, or the data defining the menu
  21611.           items may be destroyed.
  21612.  
  21613.  
  21614. The MenuInfo data structure is shown below; this version is similar to what is shown
  21615. earlier in this section, but includes additional information about menu items.
  21616.  
  21617. Warning:  The MenuInfo data structure is listed for information only;
  21618.           applications should never access it directly. This structure is
  21619.           not a valid Pascal type because of its dynamic size; it’s shown
  21620.           for conceptual purposes only.
  21621.  
  21622. TYPE  MenuInfo = RECORD
  21623.                    menuID:       INTEGER;  {menu ID}
  21624.                    menuWidth:    INTEGER;  {pixels}
  21625.                    menuHeight:   INTEGER;  {pixels}
  21626.                    menuProc:     Handle;   {handle}
  21627.                    enableFlags:  LONGINT;  {bit string}
  21628.                    menuTitle:    String;   {menu title name}
  21629.                    itemData:     ARRAY [1..X] OF
  21630.                                  itemString:  string;  {item name}
  21631.                                  itemIcon:    BYTE;    {iconnum-256}
  21632.                                  itemCmd:     char;    {item cmd key}
  21633.                                  itemMark:    char;    {item mark is a byte}
  21634.                                                        { value for }
  21635.                                                        { hierachical menus}
  21636.                                  itemStyle:   Style;   {bit string}
  21637.                    endMarker:    Byte;                 {zero-length string }
  21638.                                                        { indicates no more }
  21639.                                                        { menu items}
  21640.                  END;
  21641.  
  21642. Field descriptions
  21643.  
  21644. menuID       The menuID field contains the menu ID of the menu.
  21645. menuWidth    The menuWidth field contains the width in pixels of the menu.
  21646. menuHeight   The menuHeight field contains the height in pixels of the menu.
  21647. menuProc     The menuProc field contains a handle to the menu’s definition
  21648.              procedure.
  21649. enableFlags  The enableFlags field is a bit string which allows the menu and
  21650.              the first 31 items to be enabled or disabled. All items beyond
  21651.              31 are always enabled.
  21652. menuTitle    The menuTitle field is a string containing the menu title.
  21653. itemData     The itemData field is an array containing the following
  21654.              information for each menu item: item name, item icon number,
  21655.              item command key equivalent, item mark, and  item style. For
  21656.              hierarchical menus, the itemMark field is a byte value.
  21657. endMarker    The endMarker field is a byte value, which contains zero if
  21658.              there are no more menu items.
  21659.  
  21660. The contents of the itemData array are the same for hierarchical and nonhierarchical
  21661. menus, but for hierarchical menus the itemMark field is a byte value, which limits
  21662. hierarchical menu menuID values to between 0 and 255. Hierarchical menus numbered 236
  21663. to 255 are reserved for use by desk accessories. Desk accessories must remove their
  21664. hierarchical menus from the MenuList each time their window is not the frontmost, to
  21665. prevent hierarchical menu collisions with other desk accessories.
  21666.  
  21667.  
  21668. æKY MCEntry,MCEntryPtr,MCTable,MCTablePtr,MCTableHandle
  21669. æFp Menus.p
  21670. æT TYPE
  21671. æC MCEntryPtr = ^MCEntry;
  21672. MCTablePtr = ^MCTable;
  21673. MCTableHandle = ^MCTablePtr;
  21674. MCTable = ARRAY [0..0] OF MCEntry;  { the entries themselves }
  21675. MCEntry = RECORD
  21676.    mctID: INTEGER;                 {menu ID.  ID = 0 is the menu bar}
  21677.    mctItem: INTEGER;               {menu Item. Item = 0 is a title}
  21678.    mctRGB1: RGBColor;              {usage depends on ID and Item}
  21679.    mctRGB2: RGBColor;              {usage depends on ID and Item}
  21680.    mctRGB3: RGBColor;              {usage depends on ID and Item}
  21681.    mctRGB4: RGBColor;              {usage depends on ID and Item}
  21682.    mctReserved: INTEGER;           {reserved for internal use}
  21683.    END;
  21684.  
  21685. »Color Menu Data Structures
  21686.  
  21687. For the Macintosh II, menus can be colored in 2-bit mode or higher, in both color and
  21688. gray-scale. The menu color information is contained in a table format, but because
  21689. this format is different from the standard color table format, it is referred to as
  21690. the menu color information table, rather than the menu color table.  A menu color
  21691. information table is composed of several entries, each of  which is an MCEntry record.
  21692. These data structures are shown below:
  21693.  
  21694. TYPE  MCEntryPtr = ^MCEntry;
  21695.       MCEntry    = RECORD
  21696.                      mctID:        INTEGER;   {menu ID. ID = 0 is }
  21697.                                               { the menu bar}
  21698.                      mctItem:      INTEGER;   {menu entry. Item = 0 }
  21699.                                               { is a title}
  21700.                      mctRGB1:      RGBColor;  {usage depends on ID and Item}
  21701.                      mctRGB2:      RGBColor;  {usage depends on ID and Item}
  21702.                      mctRGB3:      RGBColor;  {usage depends on ID and Item}
  21703.                      mctRGB4:      RGBColor;  {usage depends on ID and Item}
  21704.                      mctReserved:  INTEGER;   {reserved for internal use}
  21705.                    END;
  21706.  
  21707.       MCTable       = ARRAY [0..0] of MCEntry;  {The menu entries are }
  21708.                                                 { represented in this array}
  21709.       MCTablePtr    = ^MCTable;
  21710.       MCTableHandle = ^MCTablePtr;
  21711.  
  21712. Field descriptions
  21713.  
  21714. mctID        The mctID field contains the menu ID of  the menu. A value of
  21715.              mctID = 0 means that this is the menu bar.
  21716. mctItem      The mctItem field contains the menu item. A value of item = 0
  21717.              means that the item is a menu title.
  21718. mctRGB1      The mctRGB1 field contains a color value which depends on the
  21719.              mctID and mctItem. See the description in the following section.
  21720. mctRGB2      The mctRGB2 field contains a color value which depends on the
  21721.              mctID and mctItem. See the description in the following section.
  21722. mctRGB3      The mctRGB3 field contains a color value which depends on the
  21723.              mctID and mctItem. See the description in the following section.
  21724. mctRGB4      The mctRGB4 field contains a color value which depends on the
  21725.              mctID and mctItem. See the description in the following section.
  21726. mctReserved  The mctReserved field is used internally; applications must not
  21727.              use this field.
  21728.  
  21729. The color information table is created at InitMenus time, and its handle is stored in
  21730. the global variable MenuCInfo ($D50). Like the MenuList data structure, it is only
  21731. created the first time InitMenus or InitProcMenu is called for an application.
  21732.  
  21733. A menu color information table is shown in Figure 3.
  21734.  
  21735. •••Refer to Figure 3.•••
  21736.  
  21737. Figure 3–Menu Color Information Table
  21738.  
  21739. There is always at least one entry in the color table, the last entry, which has the
  21740. arbitrary value –99 in the ID field as an “end-of-table” marker. (This means that the
  21741. value –99 cannot be used as an ID by an application.) Note that the other fields in
  21742. the “end-of-table” entry are reserved by use for Apple.  Each entry in the color
  21743. information table has seven fields.
  21744.  
  21745. The first two fields define the entry’s menu and item. The last field is used internally
  21746. and has no information for use by programmers. The other fields define colors depending
  21747. on what type of menu element the entry describes. All colors are specified as RGB
  21748. colors. There are three types of entries in the menu color information table: one
  21749. type for the menu bar, one type for menu titles, and one type for menu items.
  21750.  
  21751. The menu bar entry has ID = 0, Item = 0. There will be at most one menu bar entry in
  21752. the color information table. If there is no menu bar entry, the default menu bar
  21753. colors are black text on a white background. The fields in a menu bar entry are as
  21754. follows:
  21755.  
  21756.   •  mctRGB1 is the default color for menu titles. If a menu title doesn’t
  21757.      have an entry in the table, then this is the color used to draw the title.
  21758.   •  mctRGB2 is the default color for the background of a pulled down menu.
  21759.      If a menu title doesn’t have an entry in the table, this color is used
  21760.      as the menu’s background color.
  21761.   •  mctRGB3 is the default color for the items in a pulled down menu. If a
  21762.      menu item doesn’t have an entry in a table, and if the title for that
  21763.      menu item doesn’t also have an entry, this color will be used to color
  21764.      the mark, name, and Command-key equivalent of the item.
  21765.   •  mctRGB4 is the menu bar color.
  21766.  
  21767. The menu title entry has ID <> 0, Item = 0. There will be at most one title entry for
  21768. each menu in the color information table. If there is no title entry, the title, menu
  21769. background, and menu items are drawn using the defaults found in the menu bar entry.
  21770. If there is no menu bar entry, the default colors are black on white. The fields in a
  21771. title entry areas follows:
  21772.  
  21773.   •  mctRGBG1 is the title color.
  21774.   •  mctRGB2 is the menu bar color. This is duplicated here from the menu bar
  21775.      entry to speed menu drawing.
  21776.   •  mctRGB3 is the default color for the menu items. If a menu item doesn’t
  21777.      have an entry in the table, this color will be used to color the mark,
  21778.      name, and Command-key equivalent of the item.
  21779.   •  mctRGB4 is the menu’s background color.
  21780.  
  21781. The menu item entry has ID <> 0, Item <> 0. There will be at most one item entry for
  21782. each menu item in the color information table. If there is no entry for a particular
  21783. item, the item mark, name, and Command-key equivalent are drawn using the defaults
  21784. found in the title entry. If there is no title entry, the information in the menu bar
  21785. entry is used. If there is no menu bar entry, the mark, name, and Command-key equivalent
  21786. are drawn in black. The fields in an item entry are as follows:
  21787.  
  21788.   •  mctRGB1 is the mark color.
  21789.   •  mctRGB2 is the name color.
  21790.   •  mctRGB3 is the Command-key equivalent.
  21791.   •  mctRGB4 is the menu’s background color. It’s duplicated here to
  21792.      speed menu drawing.
  21793.  
  21794. It’s not possible to specify an icon’s color. Black and white icons are drawn in the
  21795. item’s name color. Icons may be colored using a 'cicn' resource instead of an 'ICON'
  21796. resource. When an icon is drawn in a menu, the menu defproc attempts to load the
  21797. 'cicn' resource first, and if it isn’t found, searches for the 'ICON' resource. See
  21798. the QuickDraw chapter for more information on color icons.
  21799. _______________________________________________________________________________
  21800.  
  21801. »Menu Color Information Table Resource Format
  21802.  
  21803. The resource type for a menu color information table is 'mctb'. Once read into memory,
  21804. this data is transferred into the application’s menu color information table. The
  21805. resource data format is identical to an MCTable, with the addition of a leading word
  21806. that contains the number of entries in the resource:
  21807.  
  21808. TYPE  MenuCRsrc =  RECORD
  21809.                      numEntries:  integer;
  21810.                      data:        array [1..numEntries] of MCEntry;
  21811.                    END;
  21812.  
  21813. The 'mctb' resource is loaded automatically by two routines. InitMenus attempts to
  21814. load an 'mctb' resource = 0, and if it is successful, adds the colors to the application’s
  21815. menu color information table. GetMenu attempts to load an 'mctb' resource with the
  21816. same resource ID as the menu it has loaded, and if it succeeds, it adds the colors to
  21817. the application’s menu color information table.
  21818.  
  21819. æKY AddResMenu
  21820. æFp Menus.p
  21821. æT PROCEDURE
  21822. æTN $A94D
  21823. æD PROCEDURE AddResMenu(theMenu: MenuHandle;theType: ResType);
  21824. æDT AddResMenu(theMenu,theType);
  21825. æMM 
  21826. æRT 191, 198 
  21827. æRI AddResMenu procedure  I-353, V-243, P-102
  21828. æC  
  21829. AddResMenu searches all open resource files for resources of type theType and appends
  21830. the names of all resources it finds to the given menu. Each resource name appears in
  21831. the menu as an enabled item, without an icon or mark, and in the plain character
  21832. style. The standard Menu Manager calls can be used to get the name or change its
  21833. appearance, as described in the section “Controlling the Appearance of Items”.
  21834.  
  21835. Note:  If the name of your desk accessory appears not to have been sorted
  21836.        and is inserted at the end of the Apple menu, the name is missing
  21837.        the leading null character.
  21838.  
  21839. Note:  So that you can have resources of the given type that won’t appear in
  21840.        the menu, any resource names that begin with a period (.) or a percent
  21841.        sign (%) aren’t appended by AddResMenu.
  21842.  
  21843. Use this procedure to fill a menu with the names of all available fonts or desk
  21844. accessories. For example, if you declare a variable as
  21845.  
  21846.   VAR fontMenu:  MenuHandle;
  21847.  
  21848. you can set up a menu containing all font names as follows:
  21849.  
  21850.   fontMenu := NewMenu(5,'Fonts');
  21851.   AddResMenu(fontMenu,'FONT')
  21852.  
  21853. Warning:  Before returning, AddResMenu issues the Resource Manager call
  21854.           SetResLoad(TRUE). If your program previously called SetResLoad(FALSE)
  21855.           and you still want that to be in effect after calling AddResMenu,
  21856.           you’ll have to call it again.
  21857.  
  21858. When AddResMenu or InsertResMenu is called for 'FONT' or 'FOND' resources, special
  21859. processing occurs for fontNumbers greater than or equal to $4000, as is the case for
  21860. international fonts. If the script associated with the font is currently active, then
  21861. the ItemCmd and ItemIcon fields are used to store information allowing the font names
  21862. to be displayed in the correct script.
  21863.  
  21864. There is a known problem with the AddResMenu and InsertResMenu routines, and with the
  21865. menu enable flags, when the number of items is greater than 31. Applications should
  21866. explicitly reenable or redisable all items after calling AddResMenu or InsertResMenu.
  21867. This is because only the first 31 items are affected by the enable flags: all items
  21868. 32 and greater are always enabled.
  21869.  
  21870. æKY AppendMenu
  21871. æFp Menus.p
  21872. æT PROCEDURE
  21873. æTN $A933
  21874. æD PROCEDURE AppendMenu(menu: MenuHandle;data: Str255);
  21875. æDT AppendMenu(menu,data);
  21876. æMM   
  21877. æRI AppendMenu procedure  I-352, V-243, P-102
  21878. æC  
  21879. AppendMenu adds an item or items to the end of the given menu, which must previously
  21880. have been allocated by NewMenu or read from a resource file by GetMenu. The data
  21881. string consists of the text of the menu item; it may be blank but should not be the
  21882. empty string. If it begins with a hyphen (–), the item will be a dividing line across
  21883. the width of the menu. As described in the section “Creating a Menu in Your Program”,
  21884. the following meta-characters may be embedded in the data string:
  21885.  
  21886.   Meta-character    Usage
  21887.  
  21888.   ; or Return       Separates multiple items
  21889.   ^                 Followed by an icon number, adds that icon to the item
  21890.   !                 Followed by a character, marks the item with that character
  21891.   <                 Followed by B, I, U, O, or S, sets the character style
  21892.                     of the item
  21893.   /                 Followed by a character, associates a keyboard equivalent
  21894.                     with the item
  21895.   (                 Disables the item
  21896.  
  21897. Once items have been appended to a menu, they cannot be removed or rearranged. AppendMenu
  21898. works properly whether or not the menu is in the menu list.
  21899.  
  21900. _______________________________________________________________________________
  21901.  
  21902. »CREATING A MENU IN YOUR PROGRAM
  21903. _______________________________________________________________________________
  21904.  
  21905. The best way to create your application’s menus is to set them up as resources and
  21906. read them in from a resource file. If you want your application to create the menus
  21907. itself, though, it must call the NewMenu and AppendMenu routines. NewMenu creates a
  21908. new menu data structure, returning a handle to it. AppendMenu takes a string and a
  21909. handle to a menu and adds the items in the string to the end of the menu.
  21910.  
  21911. The string passed to AppendMenu consists mainly of the text of the menu items. For a
  21912. dividing line, use one hyphen (–); AppendMenu ignores any following characters, and
  21913. draws a dotted line across the width of the menu. For a blank item, use one or more
  21914. spaces. Other characters interspersed in the string have special meaning to the Menu
  21915. Manager. These “meta-characters” are used in conjunction with text to separate menu
  21916. items or alter their appearance (for example, you can use one to disable any dividing
  21917. line or blank item). The
  21918. meta-characters aren’t displayed in the menu.
  21919.  
  21920.   Meta-character    Meaning
  21921.  
  21922.   ; or Return       Separates items
  21923.   ^                 Item has an icon
  21924.   !                 Item has a check or other mark
  21925.   <                 Item has a special character style
  21926.   /                 Item has a keyboard equivalent
  21927.   (                 Item is disabled
  21928.  
  21929. None, any, or all of these meta-characters can appear in the AppendMenu string;
  21930. they’re described in detail below. To add one text-only item to a menu would require
  21931. a simple string without any meta-characters:
  21932.  
  21933.   AppendMenu(thisMenu,'Just Enough')
  21934.  
  21935. An extreme example could use many meta-characters:
  21936.  
  21937.   AppendMenu(thisMenu,'(Too Much^1<B/T')
  21938.  
  21939. This example adds to the menu an item whose text is “Too Much”, which is disabled,
  21940. has icon number 1, is boldfaced, and can be invoked by Command-T. Your menu items
  21941. should be much simpler than this.
  21942.  
  21943. Note:  If you want any of the meta-characters to appear in the text of a
  21944.        menu item, you can include them by changing the text with the Menu
  21945.        Manager procedure SetItem.
  21946.  
  21947. _______________________________________________________________________________
  21948.  
  21949. »Multiple Items
  21950.  
  21951. Each call to AppendMenu can add one or many items to the menu. To add multiple items
  21952. in the same call, use a semicolon (;) or a Return character to separate the items.
  21953. The call
  21954.  
  21955.   AppendMenu(thisMenu,'Cut;Copy')
  21956.  
  21957. has exactly the same effect as the calls
  21958.  
  21959.   AppendMenu(thisMenu,'Cut');
  21960.   AppendMenu(thisMenu,'Copy')
  21961.  
  21962. _______________________________________________________________________________
  21963.  
  21964. »Items with Icons
  21965.  
  21966. A circumflex (^ ) followed by a digit from 1 to 9 indicates that an icon should
  21967. appear to the left of the text in the menu. The digit, called the icon number, yields
  21968. the resource ID of the icon in the resource file. Icon resource IDs 257 through 511
  21969. are reserved for menu icons; thus the Menu Manager adds 256 to the icon number to get
  21970. the proper resource ID.
  21971.  
  21972. Note:  The Menu Manager gets the icon number by subtracting 48 from the ASCII
  21973.        code of the character following the “^” (since, for example, the ASCII
  21974.        code of “1” is 49). You can actually follow the “^” with any character
  21975.        that has an ASCII code greater than 48.
  21976.  
  21977. You can also use the SetItemIcon procedure to install icons in a menu; it accepts any
  21978. icon number from 1 to 255.
  21979.  
  21980. _______________________________________________________________________________
  21981.  
  21982. »Marked Items
  21983.  
  21984. You can use an exclamation point (!) to cause a check mark or any other character to
  21985. be placed to the left of the text (or icon, if any). Follow the exclamation point
  21986. with the character of your choice; note, however, that normally you can’t type a
  21987. check mark from the keyboard. To specify a check mark, you need to take special
  21988. measures:  Declare a string variable to have the length of the desired AppendMenu
  21989. string, and assign it that string with a space following the exclamation point. Then
  21990. separately store the check mark in the position of the space.
  21991.  
  21992. For example, suppose you want to use AppendMenu to specify a menu item that has the
  21993. text “Word Wraparound” (15 characters) and a check mark to its left. You can declare
  21994. the string variable
  21995.  
  21996.   VAR s:  STRING[17];
  21997.  
  21998. and do the following:
  21999.  
  22000.   s := '! Word Wraparound';
  22001.   s[2] := CHR(checkMark);
  22002.   AppendMenu(thisMenu,s)
  22003.  
  22004. The constant checkMark is defined by the Font Manager as the character code for the
  22005. check mark.
  22006.  
  22007. Note:  The Font Manager also defines constants for certain other special
  22008.        characters that can’t normally be typed from the keyboard:  the apple
  22009.        symbol, the Command key symbol, and a diamond symbol. These symbols
  22010.        can be specified in the same way as the check mark.
  22011.  
  22012. You can call the SetItemMark or CheckItem procedures to change or clear the mark, and
  22013. the GetItemMark procedure to find out what mark, if any, is being used.
  22014.  
  22015. _______________________________________________________________________________
  22016.  
  22017. »Character Style of Items
  22018.  
  22019. The system font is the only font available for menus; however, you can vary the
  22020. character style of menu items for clarity and distinction. The meta-character for
  22021. specifying the character style of an item’s text is the less-than symbol
  22022. (<). With AppendMenu, you can assign one and only one of the stylistic variations
  22023. listed below.
  22024.  
  22025.   <B    Bold
  22026.   <I    Italic
  22027.   <U    Underline
  22028.   <O    Outline
  22029.   <S    Shadow
  22030.  
  22031. The SetItemStyle procedure allows you to assign any combination of stylistic variations
  22032. to an item. For a further discussion of character style, see the QuickDraw chapter.
  22033.  
  22034. _______________________________________________________________________________
  22035.  
  22036. »Items with Keyboard Equivalents
  22037.  
  22038. A slash (/) followed by a character associates that character with the item, allowing
  22039. the item to be invoked from the keyboard with the Command key. The specified character
  22040. (preceded by the Command key symbol) appears at the right of the item’s text in the
  22041. menu.
  22042.  
  22043. Note:  Remember to specify the character in uppercase if it’s a letter, and
  22044.        not to specify other shifted characters or numbers.
  22045.  
  22046. Given a keyboard equivalent typed by the user, you call the MenuKey function to find
  22047. out which menu item was invoked.
  22048.  
  22049. _______________________________________________________________________________
  22050.  
  22051. »Disabled Items
  22052.  
  22053. The meta-character that disables an item is the left parenthesis, “(”. A disabled
  22054. item cannot be chosen; it appears dimmed in the menu and is not highlighted when the
  22055. cursor moves over it.
  22056.  
  22057. Menu items that are used to separate groups of items (such as a line or a blank item)
  22058. should always be disabled. For example, the call
  22059.  
  22060.   AppendMenu(thisMenu,'Undo;(-;Cut')
  22061.  
  22062. adds two enabled menu items, Undo and Cut, with a disabled item consisting of a line
  22063. between them.
  22064.  
  22065. You can change the enabled or disabled state of a menu item with the DisableItem and
  22066. EnableItem procedures.
  22067.  
  22068. æKY CalcMenuSize
  22069. æFp Menus.p
  22070. æT PROCEDURE
  22071. æTN $A948
  22072. æD PROCEDURE CalcMenuSize(theMenu: MenuHandle);
  22073. æDT CalcMenuSize(theMenu);
  22074. æMM   
  22075. æRI CalcMenuSize procedure I-361
  22076. æC 
  22077. You can use CalcMenuSize to recalculate the horizontal and vertical dimensions of a
  22078. menu whose contents have been changed (and store them in the appropriate fields of
  22079. the menu record). CalcMenuSize is called internally by the Menu Manager after every
  22080. routine that changes a menu.
  22081.  
  22082. æKY CheckItem
  22083. æFp Menus.p
  22084. æT PROCEDURE
  22085. æTN $A945
  22086. æD PROCEDURE CheckItem(theMenu: MenuHandle;item: INTEGER;checked: BOOLEAN);
  22087. æDT CheckItem(theMenu,item,checked);
  22088. æMM   
  22089. æRI CheckItem procedure I-358
  22090. æC 
  22091. CheckItem places or removes a check mark at the left of the given menu item. After
  22092. you call CheckItem with checked=TRUE, a check mark will appear each subsequent time
  22093. the menu is pulled down. Calling CheckItem with checked=FALSE removes the check mark
  22094. from the menu item (or, if it’s marked with a different character, removes that
  22095. mark).
  22096.  
  22097. Menu items are initially unmarked unless you specify otherwise (such as with the “!”
  22098. meta-character in a call to AppendMenu).
  22099.  
  22100. æKY ClearMenuBar
  22101. æFp Menus.p
  22102. æT PROCEDURE
  22103. æTN $A934
  22104. æD PROCEDURE ClearMenuBar;
  22105. æDT ClearMenuBar;
  22106. æRI ClearMenuBar procedure I-354, V-247
  22107. æC 
  22108. Call ClearMenuBar to remove all menus from the menu list when you want to start
  22109. afresh with all new menus. Be sure to call DrawMenuBar to update the menu bar.
  22110.  
  22111. Note:  ClearMenuBar, like DeleteMenu, doesn’t release the memory occupied by
  22112.        the menu data structures; it merely removes them from the menu list.
  22113.  
  22114. You don’t have to call ClearMenuBar at the beginning of your program, because InitMenus
  22115. clears the menu list for you.
  22116.  
  22117. ClearMenuBar clears both the MenuList and the application’s menu color information
  22118. table.
  22119.  
  22120. æKY CountMItems
  22121. æFp Menus.p
  22122. æT FUNCTION
  22123. æTN $A950
  22124. æD FUNCTION CountMItems(theMenu: MenuHandle): INTEGER;
  22125. æDT myVariable := CountMItems(theMenu);
  22126. æRI CountMItems function I-361
  22127. æC 
  22128. CountMItems returns the number of menu items in the given menu.
  22129.  
  22130. æKY DeleteMenu
  22131. æFp Menus.p
  22132. æT PROCEDURE
  22133. æTN $A936
  22134. æD PROCEDURE DeleteMenu(menuID: INTEGER);
  22135. æDT DeleteMenu(menuID);
  22136. æRI DeleteMenu procedure I-354, V-244, P-103, 104, 167
  22137. æC 
  22138. DeleteMenu deletes a menu from the menu list. If there’s no menu with the given menu
  22139. ID in the menu list, DeleteMenu has no effect. Be sure to call DrawMenuBar to update
  22140. the menu bar; the menu titles following the deleted menu will move over to fill the
  22141. vacancy.
  22142.  
  22143. Note:  DeleteMenu simply removes the menu from the list of currently available
  22144.        menus; it doesn’t release the memory occupied by the menu data structure.
  22145.  
  22146. The DeleteMenu routine removes all color entries from the menu color information
  22147. table for the specified menuID. It first checks the hierarchical portion of the
  22148. MenuList for the menuID and, if it finds it, deletes the menu; it then returns. If
  22149. the menu is not found in the hierarchical portion of the MenuList, the regular portion
  22150. is checked.
  22151.  
  22152. The hierarchical portion of the MenuList is always checked first, so that any desk
  22153. accessories whose hierarchical menu IDs conflict with an application’s regular menu
  22154. IDs can call DeleteMenu without deleting the application’s menus.
  22155.  
  22156. æKY DelMCEntries
  22157. æFp Menus.p
  22158. æT PROCEDURE
  22159. æTN $AA60
  22160. æD PROCEDURE DelMCEntries(menuID: INTEGER;menuItem: INTEGER);
  22161. æDT DelMCEntries(menuID,menuItem);
  22162. æMM   
  22163. æRI DelMCEntries procedure  V-238
  22164. æC 
  22165. [Macintosh II]
  22166.  
  22167. The DelMCEntries routine deletes entries from the menu color information table based
  22168. on the given menuID and menuItem. If the entry is not found, no entry is removed. If
  22169. the menuItem is mctAllItems (–98), then all Items for the specified ID are removed.
  22170.  
  22171. Applications must, of course, never delete the last entry in the menu color information
  22172. table.
  22173.  
  22174. æKY DelMenuItem
  22175. æFp Menus.p
  22176. æT PROCEDURE
  22177. æTN $A952
  22178. æD PROCEDURE DelMenuItem(theMenu: MenuHandle;item: INTEGER);
  22179. æDT DelMenuItem(theMenu,item);
  22180. æMM   
  22181. æRI DelMenuItem procedure  IV-56, V-244
  22182. æC 
  22183. DelMenuItem removes the item’s color entry from the menu color information table, and
  22184. then deletes the item.
  22185.  
  22186. Note:  DelMenuItem is intended for maintaining dynamic menus (such as a
  22187.        list of open windows). It should not be used for disabling items;
  22188.        you should use DisableItem instead.
  22189.  
  22190. æKY DisableItem
  22191. æFp Menus.p
  22192. æT PROCEDURE
  22193. æTN $A93A
  22194. æD PROCEDURE DisableItem(theMenu: MenuHandle;item: INTEGER);
  22195. æDT DisableItem(theMenu,item);
  22196. æRI DisableItem procedure I-358, V-245, P-104, 168
  22197. æC 
  22198. Given a menu item number in the item parameter, DisableItem disables that menu item;
  22199. given 0 in the item parameter, it disables the entire menu.
  22200.  
  22201. Disabled menu items appear dimmed and are not highlighted when the cursor moves over
  22202. them. MenuSelect and MenuKey return 0 in the high-order word of their result if the
  22203. user attempts to invoke a disabled item. Use DisableItem to disable all menu choices
  22204. that aren’t appropriate at a given time (such as a Cut command when there’s no text
  22205. selection).
  22206.  
  22207. All menu items are initially enabled unless you specify otherwise (such as by using
  22208. the “(” meta- character in a call to AppendMenu).
  22209.  
  22210. When you disable an entire menu, call DrawMenuBar to update the menu bar. The title
  22211. of a disabled menu and every item in it are dimmed.
  22212.  
  22213. The EnableItem and DisableItem routines provide enable flags that can handle the
  22214. title and 31 menu items. All items greater than 31 will be ignored by these calls and
  22215. will always be enabled.
  22216.  
  22217. æKY DispMCInfo
  22218. æFp Menus.p
  22219. æT PROCEDURE
  22220. æTN $AA63
  22221. æD PROCEDURE DispMCInfo(menuCTbl: MCTableHandle);
  22222. æDT DispMCInfo(menuCTbl);
  22223. æMM   
  22224. æRI DispMCInfo procedure  V-239
  22225. æC 
  22226. [Macintosh II]
  22227.  
  22228. Given a handle to a menu color information table, the DispMCInfo routine disposes of
  22229. the table. No checking is done to determine whether the handle is valid. While this
  22230. procedure currently only calls DisposHandle, to ensure compatibility with any updates
  22231. to the color portion of the menu manager, it’s a good idea to use this call.
  22232.  
  22233. æKY DisposeMenu
  22234. æFp Menus.p
  22235. æT PROCEDURE
  22236. æTN $A932
  22237. æD PROCEDURE DisposeMenu(theMenu: MenuHandle);
  22238. æDT DisposeMenu(theMenu);
  22239. æMM   
  22240. æRI DisposeMenu procedure I-352, P-103, 168
  22241. æC  
  22242. Assembly-language note:  The macro you invoke to call DisposeMenu from
  22243.                          assembly language is named _DisposMenu.
  22244.  
  22245. Call DisposeMenu to release the memory occupied by a menu that you allocated with
  22246. NewMenu. (For menus read from a resource file with GetMenu, use the Resource Manager
  22247. procedure ReleaseResource instead.) This is useful if you’ve created temporary menus
  22248. that you no longer need.
  22249.  
  22250. Warning:  Make sure you remove the menu from the menu list (with DeleteMenu)
  22251.           before disposing of it.
  22252.  
  22253. æKY DrawMenuBar
  22254. æFp Menus.p
  22255. æT PROCEDURE
  22256. æTN $A937
  22257. æD PROCEDURE DrawMenuBar;
  22258. æDT DrawMenuBar;
  22259. æMM   
  22260. æRI DrawMenuBar procedure I-354, V-244, P-101, 104, 169
  22261. æC 
  22262. DrawMenuBar redraws the menu bar according to the menu list, incorporating any changes
  22263. since the last call to DrawMenuBar. This procedure should always be called after a
  22264. sequence of InsertMenu or DeleteMenu calls, and after ClearMenuBar, SetMenuBar, or
  22265. any other routine that changes the menu list.
  22266.  
  22267. DrawMenuBar now properly highlights the selected menu title, if there is one. If your
  22268. application program assumed that DrawMenuBar would redraw the menu incorrectly, and
  22269. called HiliteMenu or FlashMenuBar to compensate, what happens now is that the menu
  22270. bar is redrawn properly, and the next call to HiliteMenu or FlashMenuBar causes the
  22271. highlighted title to become unhighlighted.
  22272.  
  22273. æKY EnableItem
  22274. æFp Menus.p
  22275. æT PROCEDURE
  22276. æTN $A939
  22277. æD PROCEDURE EnableItem(theMenu: MenuHandle;item: INTEGER);
  22278. æDT EnableItem(theMenu,item);
  22279. æRI EnableItem procedure I-358, V-245, P-104, 170
  22280. æC  
  22281. Given a menu item number in the item parameter, EnableItem enables the item
  22282. (which may have been disabled with the DisableItem procedure, or with the “(” meta-character
  22283. in the AppendMenu string).
  22284.  
  22285. Given 0 in the item parameter, EnableItem enables the menu as a whole, but any items
  22286. that were disabled separately (before the entire menu was disabled) remain so. When
  22287. you enable an entire menu, call DrawMenuBar to update the menu bar.
  22288.  
  22289. The item or menu title will no longer appear dimmed and can be chosen like any other
  22290. enabled item or menu.
  22291.  
  22292. æKY FlashMenuBar
  22293. æFp Menus.p
  22294. æT PROCEDURE
  22295. æTN $A94C
  22296. æD PROCEDURE FlashMenuBar(menuID: INTEGER);
  22297. æDT FlashMenuBar(menuID);
  22298. æMM   
  22299. æRI FlashMenuBar procedure I-361, V-246
  22300. æC 
  22301. If menuID is 0 (or isn’t the ID of any menu in the menu list), FlashMenuBar inverts
  22302. the entire menu bar; otherwise, it inverts the title of the given menu. You can call
  22303. FlashMenuBar(0) twice to blink the menu bar.
  22304.  
  22305. FlashMenuBar(0) still inverts the complete menu bar. Strange colors may result if
  22306. HiliteMenu, or FlashMenuBar with a nonzero parameter, are called while the menu bar
  22307. is inverted.
  22308.  
  22309. FlashMenuBar has been modified so that only one menu may be highlighted at a time
  22310. (see HiliteMenu). If no menu is currently highlighted, calling FlashMenuBar with a
  22311. nonzero parameter highlights that menu. If  the highlighted menu is different than
  22312. the one being “flashed”, the previously highlighted menu is first restored to normal,
  22313. and the new menu is highlighted.
  22314.  
  22315. æKY GetItem
  22316. æFp Menus.p
  22317. æT PROCEDURE
  22318. æTN $A946
  22319. æD PROCEDURE GetItem(theMenu: MenuHandle;item: INTEGER;VAR itemString: Str255);
  22320. æDT GetItem(theMenu,item,itemString);
  22321. æRI GetItem procedure I-358, P-104, 172
  22322. æC 
  22323. GetItem returns the text of the given menu item in itemString. It doesn’t place any
  22324. meta-characters in the string. This procedure is useful for getting the name of a
  22325. menu item that was installed with AddResMenu or InsertResMenu.
  22326.  
  22327. æKY GetItemCmd
  22328. æFp Menus.p
  22329. æT PROCEDURE
  22330. æTN $A84E
  22331. æD PROCEDURE GetItemCmd(theMenu: MenuHandle;item: INTEGER;VAR cmdChar: CHAR);
  22332. æDT GetItemCmd(theMenu,item,cmdChar);
  22333. æRI GetItemCmd procedure  V-240
  22334. æC 
  22335. [Macintosh Plus, Macintosh SE, Macintosh II]
  22336.  
  22337. The GetItemCmd routine may be used to determine whether a menu item has a submenu
  22338. attached. For a menu item with a submenu, the returned cmdChar will have the value
  22339. $1B.
  22340.  
  22341. æKY GetItemIcon
  22342. æFp Menus.p
  22343. æT PROCEDURE
  22344. æTN $A93F
  22345. æD PROCEDURE GetItemIcon(theMenu: MenuHandle;item: INTEGER;VAR iconNum: Byte);
  22346. æDT GetItemIcon(theMenu,item,iconNum);
  22347. æRI GetItemIcon procedure I-360, V-246
  22348. æC 
  22349. Assembly-language note:  The macro you invoke to call GetItemIcon from
  22350.                          assembly language is named _GetItmIcon.
  22351.  
  22352. GetItemIcon returns the icon number associated with the given menu item, as an integer
  22353. from 1 to 255, or 0 if the item has not been associated with an icon. The icon number
  22354. is 256 less than the icon’s resource ID.
  22355.  
  22356. The GetItemIcon procedure may be used to determine the script number of a font item
  22357. that is the name of an international script.
  22358.  
  22359. æKY GetItemMark
  22360. æFp Menus.p
  22361. æT PROCEDURE
  22362. æTN $A943
  22363. æD PROCEDURE GetItemMark(theMenu: MenuHandle;item: INTEGER;VAR markChar: CHAR);
  22364. æDT GetItemMark(theMenu,item,markChar);
  22365. æRI GetItemMark procedure I-359, V-246
  22366. æC 
  22367. Assembly-language note:  The macro you invoke to call GetItemMark from
  22368.                          assembly language is named _GetItmMark.
  22369.  
  22370. GetItemMark returns in markChar whatever character the given menu item is marked
  22371. with, or the predefined constant noMark if no mark is present.
  22372.  
  22373. The GetItemMark procedure may be used to determine the ID of the hierarchical menu
  22374. associated with a menu item.
  22375.  
  22376. æKY GetItemStyle
  22377. æFp Menus.p
  22378. æT PROCEDURE
  22379. æTN $A941
  22380. æD PROCEDURE GetItemStyle(theMenu: MenuHandle;item: INTEGER;VAR chStyle: Style);
  22381. æDT GetItemStyle(theMenu,item,chStyle);
  22382. æRI GetItemStyle procedure I-360, V-247, N61-1
  22383. æC 
  22384. Assembly-language note:  The macro you invoke to call GetItemStyle from
  22385.                          assembly language is named _GetItmStyle.
  22386.  
  22387. GetItemStyle returns the character style of the given menu item in chStyle.
  22388.  
  22389. There is a possible bug in this routine, depending on the interpretation of the
  22390. address of the VAR parameter chStyle. GetItemStyle assumes that the address on the
  22391. stack points to a word with chStyle in the low byte. MPW Pascal passes the byte
  22392. address of chStyle regardless of whether it’s in the high or low byte of a word.
  22393. Since there has never been a bug report for this “problem”, it is listed here for
  22394. information only.
  22395.  
  22396. æKY GetMCEntry
  22397. æFp Menus.p
  22398. æT FUNCTION
  22399. æTN $AA64
  22400. æD FUNCTION GetMCEntry(menuID: INTEGER;menuItem: INTEGER): MCEntryPtr;
  22401. æDT myVariable := GetMCEntry(menuID,menuItem);
  22402. æRI GetMCEntry function  V-239
  22403. æC 
  22404. [Macintosh II]
  22405.  
  22406. The GetMCEntry routine finds the entry of the specified menuID and menuItem in the
  22407. menu color information table, and returns a pointer into the table. If the entry is
  22408. not found, a NIL pointer is returned.
  22409.  
  22410. Note:  Entries are not removed from the table. Applications must not remove
  22411.        entries from the table directly; they should always use the procedure
  22412.        DelMCEntries to remove entries.
  22413.  
  22414. Warning:  The menu color information table is relocatable, so the GetMCEntry
  22415.           return value may not be valid across traps that move or purge memory.
  22416.           Applications should make a copy of the record in this case.
  22417.  
  22418. æKY GetMCInfo
  22419. æFp Menus.p
  22420. æT FUNCTION
  22421. æTN $AA61
  22422. æD FUNCTION GetMCInfo: MCTableHandle;
  22423. æDT myVariable := GetMCInfo;
  22424. æMM   
  22425. æRI GetMCInfo function  V-239
  22426. æC 
  22427. [Macintosh II]
  22428.  
  22429. The GetMCInfo routine creates a copy of the current menu color information table and
  22430. returns a handle to the copy. It doesn’t affect the current menu color information
  22431. table. If the copy fails, a NIL handle is returned.
  22432.  
  22433. æKY GetMenu
  22434. æFp Menus.p
  22435. æT FUNCTION
  22436. æTN $A9BF
  22437. æD FUNCTION GetMenu(resourceID: INTEGER): MenuHandle;
  22438. æDT myVariable := GetMenu(resourceID);
  22439. æMM 
  22440. æRT 78
  22441. æRI GetMenu function I-351, V-243, N78-2, P-102, 172
  22442. æC 
  22443. Assembly-language note:  The macro you invoke to call GetMenu from
  22444.                          assembly language is named _GetRMenu.
  22445.  
  22446. GetMenu returns a menu handle for the menu having the given resource ID. It calls the
  22447. Resource Manager to read the menu from the resource file into a menu record in memory.
  22448. GetMenu stores the handle to the menu definition procedure in the menu record, reading
  22449. the procedure from the resource file into memory if necessary. If the menu or the
  22450. menu definition procedure can’t be read from the resource file, GetMenu returns NIL.
  22451. To use the menu, you must call InsertMenu to place it in the menu list and DrawMenuBar
  22452. to update the menu bar to include the new title.
  22453.  
  22454. Warning:  Call GetMenu only once for a particular menu. If you need the menu
  22455.           handle to a menu that’s already in memory, use the Resource Manager
  22456.           function GetResource.
  22457.  
  22458. To release the memory occupied by a menu that you read from a resource file with
  22459. GetMenu, use the Resource Manager procedure ReleaseResource.
  22460.  
  22461. After loading a 'MENU' resource, GetMenu attempts to load an 'mctb' resource with the
  22462. same resource ID. If an 'mctb' is loaded, all of the entries are added to the application’s
  22463. menu color information table by making a call to SetMCEntries.
  22464.  
  22465. æKY GetMenuBar
  22466. æFp Menus.p
  22467. æT FUNCTION
  22468. æTN $A93B
  22469. æD FUNCTION GetMenuBar: Handle;
  22470. æDT myVariable := GetMenuBar;
  22471. æMM   
  22472. æRI GetMenuBar function I-355, P-172
  22473. æC 
  22474. GetMenuBar creates a copy of the current menu list and returns a handle to the copy.
  22475. You can then add or remove menus from the menu list (with InsertMenu, DeleteMenu, or
  22476. ClearMenuBar), and later restore the saved menu list with SetMenuBar. To release the
  22477. memory occupied by the saved menu list, use the Memory Manager procedure DisposHandle.
  22478.  
  22479. Warning:  GetMenuBar doesn’t copy the menus themselves, only a list
  22480.           containing their handles. Do not dispose of any menus that
  22481.           might be in a saved menu list.
  22482.  
  22483. æKY GetMHandle
  22484. æFp Menus.p
  22485. æT FUNCTION
  22486. æTN $A949
  22487. æD FUNCTION GetMHandle(menuID: INTEGER): MenuHandle;
  22488. æDT myVariable := GetMHandle(menuID);
  22489. æRI GetMHandle function I-361, V-246
  22490. æC 
  22491. Given the menu ID of a menu currently installed in the menu list, GetMHandle returns
  22492. a handle to that menu; given any other menu ID, it returns NIL.
  22493.  
  22494. The GetMHandle routine looks for the menu in the hierarchical portion of the MenuList
  22495. first, and if it isn’t found, looks in the regular portion of the MenuList. The
  22496. routine has no way to determine whether the returned menu is associated with a menu,
  22497. pop-up, or hierarchical menu. Presumably the application will contain that information.
  22498.  
  22499. æKY GetNewMBar
  22500. æFp Menus.p
  22501. æT FUNCTION
  22502. æTN $A9C0
  22503. æD FUNCTION GetNewMBar(menuBarID: INTEGER): Handle;
  22504. æDT myVariable := GetNewMBar(menuBarID);
  22505. æMM   
  22506. æRI GetNewMBar function I-354, V-247, P-102, 172
  22507. æC 
  22508. GetNewMBar creates a menu list as defined by the menu bar resource having the given
  22509. resource ID, and returns a handle to it. If the resource isn’t already in memory,
  22510. GetNewMBar reads it into memory from the resource file. If the resource can’t be
  22511. read, GetNewMBar returns NIL. GetNewMBar calls GetMenu to get each of the individual
  22512. menus.
  22513.  
  22514. To make the menu list created by GetNewMBar the current menu list, call SetMenuBar.
  22515. To release the memory occupied by the menu list, use the Memory Manager procedure
  22516. DisposHandle.
  22517.  
  22518. Warning:  You don’t have to know the individual menu IDs to use GetNewMBar,
  22519.           but that doesn’t mean you don’t have to know them at all:  To do
  22520.           anything further with a particular menu, you have to know its ID
  22521.           or its handle (which you can get by passing the ID to GetMHandle,
  22522.           as described in the section “Miscellaneous Routines”).
  22523.  
  22524. GetNewMBar begins by calling ClearMenuBar, which clears both the MenuList and the
  22525. application’s menu color information table. Before returning the Handle to the new
  22526. MenuList, it restores the previous MenuList. It doesn’t restore the previous menu
  22527. color information table. If that is desired, the application must use GetMCInfo
  22528. before calling GetNewMBar, and call SetMCInfo afterwards.
  22529.  
  22530. æKY HiliteMenu
  22531. æFp Menus.p
  22532. æT PROCEDURE
  22533. æTN $A938
  22534. æD PROCEDURE HiliteMenu(menuID: INTEGER);
  22535. æDT HiliteMenu(menuID);
  22536. æMM   
  22537. æRI HiliteMenu procedure I-357, V-245
  22538. æC 
  22539. HiliteMenu highlights the title of the given menu, or does nothing if the title is
  22540. already highlighted. Since only one menu title can be highlighted at a time, it
  22541. unhighlights any previously highlighted menu title. If menuID is 0 (or isn’t the ID
  22542. of any menu in the menu list), HiliteMenu simply unhighlights whichever menu title is
  22543. highlighted (if any).
  22544.  
  22545. After MenuSelect or MenuKey, your application should perform the chosen task and then
  22546. call HiliteMenu(0) to unhighlight the chosen menu title.
  22547.  
  22548. Assembly-language note:  The global variable TheMenu contains the menu ID
  22549.                          of the currently highlighted menu.
  22550.  
  22551. Previously, highlighting a menu title meant inverting the title rectangle, and dehighlighting
  22552. it meant reinverting it, so that it returned to normal.  With color titles, color
  22553. inversion is usually aesthetically unacceptable, so there is a need to draw the
  22554. highlighted menu title.
  22555.  
  22556. HiliteMenu begins by restoring the bits behind the currently highlighted title
  22557. (if there is one). It then saves the bits behind the title rectangle, and draws the
  22558. highlighted title. HiliteMenu(0) dehighlights the currently highlighted menu by
  22559. restoring the bits behind the title.
  22560.  
  22561. Note:  Because an application can only save the bits behind the menu title,
  22562.        only one menu title can be highlighted at a time.
  22563.  
  22564. æKY hMenuCmd,hierMenu,hPopUpMsg,mctAllItems,mctLastIDIndic,dsMBarNFnd,dsHMenuFindErr
  22565. æFp Menus.p
  22566. æC 
  22567. CONST
  22568.   hMenuCmd        = $1B;  {itemCmd == $1B ==> hierarchical menu }
  22569.                           { attached to this item}
  22570.   hierMenu        = –1;   {for use as "beforeID" with InsertMenu}
  22571.   hPopUpMsg       =  3;   {pop-up menu placement, asks the defproc to }
  22572.                           { calculate the menu rectangle of the pop-up menu}
  22573.   mctAllItems     = –98;  {for use as a "menuItem" with DelMCEntries}
  22574.   mctLastIDIndic  = -99;  {last color table entry has this in ID field}
  22575.   dsMBarNFnd      = 85;   {SysErr code indicating MBDF not found. Used }
  22576.                           { by InitProcMenu and InitMenu}
  22577.   dsHMenuFindErr  = 86;   {SysErr code indicating recursive }
  22578.                           { hierarchical menus defined. Used by MenuKey.}
  22579.  
  22580. æKY InitMenus
  22581. æFp Menus.p
  22582. æT PROCEDURE
  22583. æTN $A930
  22584. æD PROCEDURE InitMenus;
  22585. æDT InitMenus;
  22586. æMM 
  22587. æRT 211
  22588. æRI InitMenus procedure I-351, V-242, P-101, 107, 175
  22589. æC 
  22590. InitMenus initializes the Menu Manager. It allocates space for the menu list (a
  22591. relocatable block in the heap large enough for the maximum-size menu list), and draws
  22592. the (empty) menu bar. Call InitMenus once before all other Menu Manager routines. An
  22593. application should never have to call this procedure more than once; to start afresh
  22594. with all new menus, use ClearMenuBar.
  22595.  
  22596. Note:  The Window Manager initialization procedure InitWindows has already
  22597.        drawn the empty menu bar; InitMenus redraws it.
  22598.  
  22599. The InitMenus routine now allocates a dynamic MenuList structure with no menus or
  22600. hierarchical menus. After allocating the initial MenuList, it attempts to load an
  22601. 'mctb' resource = 0. If the user has chosen default menu color values, this 'mctb'
  22602. resource = 0 will exist in the System file. If the 'mctb' is loaded, the information
  22603. contained in the resource is added to the menu color information table by making a
  22604. call to SetMCEntries. If there is an 'mctb' resource = 0 among the application’s
  22605. resources, this will be loaded instead of the default 'mctb' in the System file.
  22606.  
  22607. æKY InitProcMenu
  22608. æFp Menus.p
  22609. æT PROCEDURE
  22610. æTN $A808
  22611. æD PROCEDURE InitProcMenu(resID: INTEGER);
  22612. æDT InitProcMenu(resID);
  22613. æMM   
  22614. æRI InitProcMenu procedure  V-238
  22615. æC 
  22616. [Macintosh Plus, Macintosh SE, Macintosh II]
  22617.  
  22618. Note:  The mbVariant field is contained in the low three bits of the
  22619.        mbResID. The high order 13 bits are used to load the proper 'MBDF'.
  22620.  
  22621. The InitProcMenu routine is called when an application has a custom menu bar defproc,
  22622. 'MBDF'. InitProcMenu allocates a new MenuList if it hasn’t already been allocated by
  22623. a previous call to InitMenus, and the mbResID is stored in the mbResID field in the
  22624. MenuList (note that InitWindows calls InitMenus, so that it can obtain the menu bar
  22625. height).
  22626.  
  22627. The effect of InitProcMenu lasts for the duration of the application only; the next
  22628. InitMenus call will replace the mbResID field in the MenuList with the default value
  22629. of zero. This affects applications such as development systems, which use multiple
  22630. heaps and whose “applications” call InitMenus.
  22631.  
  22632. Note:  Apple reserves mbResID values $000–$100 for its own use.
  22633.  
  22634. æKY InsertMenu
  22635. æFp Menus.p
  22636. æT PROCEDURE
  22637. æTN $A935
  22638. æD PROCEDURE InsertMenu(theMenu: MenuHandle;beforeID: INTEGER);
  22639. æDT InsertMenu(theMenu,beforeID);
  22640. æMM   
  22641. æRI InsertMenu procedure I-353, V-244, P-98, 102, 104, 175
  22642. æC 
  22643. InsertMenu inserts a menu into the menu list before the menu whose menu ID equals
  22644. beforeID. If beforeID is 0 (or isn’t the ID of any menu in the menu
  22645. list), the new menu is added after all others. If the menu is already in the menu
  22646. list or the menu list is already full, InsertMenu does nothing. Be sure to call
  22647. DrawMenuBar to update the menu bar.
  22648.  
  22649. The InsertMenu routine can be used to add a hierarchical menu to the Menulist. If
  22650. beforeID is equal to –1, the menu is a hierarchical menu. If beforeID is greater than
  22651. or equal to zero, the menu is a nonhierarchical menu.
  22652.  
  22653. It isn’t necessary for every menu in the hierarchical menu portion of the MenuList to
  22654. be currently in use; that is, attached to a menu item. Hierarchical menus that are
  22655. currently unused, but may be used some time later by the application, may be stored
  22656. there, and attached to menu items only as needed. You should realize that this can
  22657. cause problems if the unattached submenus have items with Command-key equivalents,
  22658. because MenuKey will find these equivalents even though the menu is unattached.
  22659.  
  22660. æKY InsertResMenu
  22661. æFp Menus.p
  22662. æT PROCEDURE
  22663. æTN $A951
  22664. æD PROCEDURE InsertResMenu(theMenu: MenuHandle;theType: ResType;afterItem: INTEGER);
  22665. æDT InsertResMenu(theMenu,theType,afterItem);
  22666. æMM   
  22667. æRI InsertResMenu procedure I-353, V-243
  22668. æC 
  22669. InsertResMenu is the same as AddResMenu (above) except that it inserts the resource
  22670. names in the menu where specified by the afterItem parameter:  If afterItem is 0, the
  22671. names are inserted before the first menu item; if it’s the item number of an item in
  22672. the menu, they’re inserted after that item; if it’s equal to or greater than the last
  22673. item number, they’re appended to the menu.
  22674.  
  22675. Note:  InsertResMenu inserts the names in the reverse of the order that
  22676.        AddResMenu appends them. For consistency between applications in
  22677.        the appearance of menus, use AddResMenu instead of InsertResMenu if
  22678.        possible.
  22679.  
  22680. æKY InsMenuItem
  22681. æFp Menus.p
  22682. æT PROCEDURE
  22683. æTN $A826
  22684. æD PROCEDURE InsMenuItem(theMenu: MenuHandle;itemString: Str255;afterItem: INTEGER);
  22685. æDT InsMenuItem(theMenu,itemString,afterItem);
  22686. æMM   
  22687. æRI InsMenuItem procedure  IV-55
  22688. æC 
  22689. InsMenuItem inserts an item or items into the given menu where specified by the
  22690. afterItem parameter. If afterItem is 0, the items are inserted before the first menu
  22691. item; if it’s the item number of an item in the menu, they’re inserted after that
  22692. item; if it’s equal to or greater than the last item number, they’re appended to the
  22693. menu.
  22694.  
  22695. The contents of itemString are parsed as in the AppendMenu procedure. Multiple items
  22696. are inserted in the reverse of their order in itemString.
  22697.  
  22698. æKY mDrawMsg,mChooseMsg,mSizeMsg
  22699. æFp Menus.p
  22700. æC 
  22701. _______________________________________________________________________________
  22702.  
  22703. »The Menu Definition Procedure
  22704.  
  22705. The menu definition procedure is usually written in assembly language, but may be
  22706. written in any high-level language.
  22707.  
  22708. Assembly-language note:  The procedure’s entry point must be at the beginning.
  22709.  
  22710. You may choose any name you wish for the menu definition procedure. Here’s how you
  22711. would declare one named MyMenu:
  22712.  
  22713. PROCEDURE MyMenu (message:  INTEGER; theMenu:  MenuHandle; VAR menuRect:  Rect;
  22714.                   hitPt:  Point; VAR whichItem:  INTEGER);
  22715.  
  22716. The message parameter identifies the operation to be performed. It has one of the
  22717. following values:
  22718.  
  22719. CONST  mDrawMsg   = 0; {draw the menu}
  22720.        mChooseMsg = 1; {tell which item was chosen and highlight it}
  22721.        mSizeMsg   = 2; {calculate the menu's dimensions}
  22722.  
  22723. The parameter theMenu indicates the menu that the operation will affect. MenuRect is
  22724. the rectangle (in global coordinates) in which the menu is located; it’s used when
  22725. the message is mDrawMsg or mChooseMsg.
  22726.  
  22727. Note:  MenuRect is declared as a VAR parameter not because its value is
  22728.        changed, but because of a Pascal feature that will cause an error
  22729.        when that parameter isn’t used.
  22730.  
  22731. The message mDrawMsg tells the menu definition procedure to draw the menu inside
  22732. menuRect. The current grafPort will be the Window Manager port. (For details on
  22733. drawing, see the QuickDraw chapter.) The standard menu definition procedure figures
  22734. out how to draw the menu items by looking in the menu record at the data that defines
  22735. them; this data is described in detail under “Formats of Resources for Menus” below.
  22736. For menus of your own definition, you may set up the data defining the menu items any
  22737. way you like, or even omit it altogether
  22738. (in which case all the information necessary to draw the menu would be in the menu
  22739. definition procedure itself). You should also check the enableFlags field of the menu
  22740. record to see whether the menu is disabled (or whether any of the menu items are
  22741. disabled, if you’re using all the flags), and if so, draw it in gray.
  22742.  
  22743. Note:  MenuKey will always search the menuData field of a MenuInfo record for
  22744.        Command-key equivalents until it finds a zero where a standard menu
  22745.        title should be, even if the MenuInfo record is for one of your own
  22746.        'MDEF' resources. To prevent MenuKey from finding a Command-key
  22747.        equivalent in your MenuInfo record, put a couple of bytes of zeros
  22748.        just after the menu’s title.
  22749.  
  22750. Warning:  Don’t change the font from the system font for menu text.
  22751.           (The Window Manager port uses the system font.)
  22752.  
  22753. When the menu definition procedure receives the message mChooseMsg, the hitPt parameter
  22754. is the mouse location (in global coordinates), and the whichItem parameter is the
  22755. item number of the last item that was chosen from this menu
  22756. (whichItem is initially set to 0). The procedure should determine whether the mouse
  22757. location is in an enabled menu item, by checking whether hitPt is inside menuRect,
  22758. whether the menu is enabled, and whether hitPt is in an enabled menu item:
  22759.  
  22760.   •  If the mouse location is in an enabled menu item, unhighlight whichItem
  22761.      and highlight the new item (unless the new item is the same as the
  22762.      whichItem), and return the item number of the new item in whichItem.
  22763.   •  If the mouse location isn’t in an enabled item, unhighlight whichItem
  22764.      and return 0.
  22765.  
  22766. Note:  When the Menu Manager needs to make a chosen menu item blink, it
  22767.        repeatedly calls the menu definition procedure with the message
  22768.        mChooseMsg, causing the item to be alternately highlighted and
  22769.        unhighlighted.
  22770.  
  22771. Finally, the message mSizeMsg tells the menu definition procedure to calculate the
  22772. horizontal and vertical dimensions of the menu and store them in the menuWidth and
  22773. menuHeight fields of the menu record.
  22774.  
  22775. The following section describes changes to the default menu definition procedure
  22776. ('MDEF' resource 0); some of the information presented in this section is accessible
  22777. only through assembly language.
  22778.  
  22779. Note:  These features will work with the 64K ROM if the new menu definition
  22780.        procedure is in the system resource file.
  22781.  
  22782. »Variable Size Fonts
  22783.  
  22784. Menus are displayed in the system font. Since the system font and font size can now
  22785. be changed, the menu definition procedure calls the QuickDraw procedure GetFontInfo
  22786. for the system font to determine the height of menu items
  22787.  
  22788. »Scrolling Menus
  22789.  
  22790. The default menu definition procedure allows longer menus by implementing automatic
  22791. scrolling. If the entire menu cannot be drawn on screen, dragging the cursor below
  22792. the last displayed item will cause the items in the menu to scroll up. Similarly, if
  22793. items have been scrolled past the top of the menu, dragging the cursor into the
  22794. highlighted portion of the menu bar will cause the menu to scroll back down. The
  22795. maximum number of items that can be drawn on the standard Macintosh screen with this
  22796. new menu definition function is 19 (instead of 20).
  22797.  
  22798. Warning:  You should not disable any menu items in a menu containing more than
  22799.           31 items because the enableFlags field of the MenuInfoRec can only
  22800.           handle 31 items.
  22801.  
  22802. æKY MenuChoice
  22803. æFp Menus.p
  22804. æT FUNCTION
  22805. æTN $AA66
  22806. æD FUNCTION MenuChoice: LONGINT;
  22807. æDT myVariable := MenuChoice;
  22808. æRI MenuChoice function  V-240, P-103, 105, 176
  22809. æC 
  22810. [Macintosh II]
  22811.  
  22812. The MenuChoice routine is called only after the result from MenuSelect is zero. It
  22813. determines if the mouse-up event that terminated MenuSelect was in a disabled menu
  22814. item. When the mouse button is released over a disabled item in an application menu,
  22815. MenuChoice returns a long integer whose high-order word is the menuID of the menu,
  22816. and whose low-order word is the menu item number for the disabled item “chosen”. If
  22817. the item number is zero, then the mouse-up event occurred when the mouse was either
  22818. in the menu title or completely outside the menu; there is no way to distinguish
  22819. between the two.
  22820.  
  22821. Note:  This information is available on the Macintosh Plus and Macintosh SE
  22822.        by directly querying the long word stored in the global variable
  22823.        MenuDisable ($B54).
  22824.  
  22825. This feature has been added to MenuChoice to make it possible for applications to
  22826. provide better help facilities. For example, when the Finder calls MenuChoice, and
  22827. determines that a user has chosen the disabled menu item “Empty Trash” with the
  22828. Finder, the application could display a message telling the user that it can’t empty
  22829. the trash because there is nothing currently in the trash.
  22830.  
  22831. The new MenuChoice capability is implemented by continual updates of the global
  22832. variable MenuDisable ($B54) whenever a menu is down. As the mouse moves over each
  22833. item, MenuDisable is updated to reflect the current menu and item ID. The code that
  22834. changes the value in MenuDisable resides in the standard menu defproc. The return
  22835. value is undefined when the menu uses a custom menu defproc, unless the custom defproc
  22836. also supports this feature.
  22837.  
  22838. æKY MenuKey
  22839. æFp Menus.p
  22840. æT FUNCTION
  22841. æTN $A93E
  22842. æD FUNCTION MenuKey(ch: CHAR): LONGINT;
  22843. æDT myVariable := MenuKey(ch);
  22844. æMM   
  22845. æRI MenuKey function  I-356, V-245, P-105, 176
  22846. æC 
  22847. MenuKey maps the given character to the associated menu and item for that character.
  22848. When you get a key-down event with the Command key held down—or an auto-key event, if
  22849. the command being invoked is repeatable—call MenuKey with the character that was
  22850. typed. MenuKey highlights the appropriate menu title, and returns a long integer
  22851. containing the menu ID in its high-order word and the menu item number in its low-order
  22852. word, just as MenuSelect does (see Figure 4 above). After performing the chosen task,
  22853. your application should call HiliteMenu(0) to remove the highlighting from the menu
  22854. title.
  22855.  
  22856. If the given character isn’t associated with any enabled menu item currently in the
  22857. menu list, MenuKey returns 0 in the high-order word of the long integer, and the
  22858. low-order word is undefined.
  22859.  
  22860. If the given character invokes a menu item in a menu belonging to a desk accessory,
  22861. MenuKey (like MenuSelect) passes the menu ID and item number to the Desk Manager
  22862. procedure SystemMenu for processing, and returns 0 to your application in the high-order
  22863. word of the result.
  22864.  
  22865. Note:  There should never be more than one item in the menu list with the
  22866.        same keyboard equivalent, but if there is, MenuKey returns the first
  22867.        such item it encounters, scanning the menus from right to left and
  22868.        their items from top to bottom.
  22869.  
  22870. The MenuKey routine first searches for the given key in the regular portion of the
  22871. MenuList, and if it doesn’t find it there, searches for the key in the hierarchical
  22872. portion of the MenuList. If the key is in a hierarchical menu, MenuKey highlights the
  22873. menu title of the menu that “owns” the hierarchical menu. Ownership in this case
  22874. means the menu in the menu bar that the user would first encounter on the way to the
  22875. item with the given Command-key equivalent. Because several levels of hierarchy are
  22876. possible, this traversal may not always be obvious to the user. As before, after
  22877. performing the chosen task, your application should call HiliteMenu(0) to remove the
  22878. highlighting from the menu title.
  22879.  
  22880. Note:  The Command-key codes $1B (Control-[ ) through $1F (Control- _ ) are
  22881.        reserved by Apple Computer to indicate meanings other than Command-key
  22882.        equivalents. These key codes are ignored by MenuKey, and a result of
  22883.        zero is always returned. Applications must never use these codes for
  22884.        their own use.
  22885.  
  22886. The global variable TheMenu contains the ID of the highlighted menu in the menu bar.
  22887. If an item from a hierarchical menu is chosen, TheMenu contains the ID of the “owner”
  22888. menu, not the ID of the hierarchical menu.
  22889.  
  22890. It’s possible, although undesirable, to define so-called “circular” hierarchical
  22891. menus. A circular hierarchical menu is one in which a submenu has an “ancestor” that
  22892. is also one of its “offspring”. If MenuKey detects circular hierarchical menus, a
  22893. SysError = 86 = #DSHMenuFndErr is generated.
  22894.  
  22895. æKY MenuSelect
  22896. æFp Menus.p
  22897. æT FUNCTION
  22898. æTN $A93D
  22899. æD FUNCTION MenuSelect(startPt: Point): LONGINT;
  22900. æDT myVariable := MenuSelect(startPt);
  22901. æMM   
  22902. æRI MenuSelect function  I-355, V-244, P-36, 103, 105, 176
  22903. æC 
  22904. When there’s a mouse-down event in the menu bar, the application should call MenuSelect
  22905. with startPt equal to the point (in global coordinates) where the mouse button was
  22906. pressed. MenuSelect keeps control until the mouse button is released, tracking the
  22907. mouse, pulling down menus as needed, and highlighting enabled menu items under the
  22908. cursor. When the mouse button is released over an enabled item in an application
  22909. menu, MenuSelect returns a long integer whose high-order word is the menu ID of the
  22910. menu, and whose low-order word is the menu item number for the item chosen (see
  22911. Figure 4). It leaves the selected menu title highlighted. After performing the chosen
  22912. task, your application should call HiliteMenu(0) to remove the highlighting from the
  22913. menu title.
  22914.  
  22915. If no choice is made, MenuSelect returns 0 in the high-order word of the long integer,
  22916. and the low-order word is undefined. This includes the case where the mouse button is
  22917. released over a disabled menu item (such as Cut, Copy, Clear, or one of the dividing
  22918. lines in Figure 4), over any menu title, or outside the menu.  In the case of a
  22919. disabled menu item, an application can still determine which item was chosen.  See
  22920. the description of the MenuChoice routine for further details.
  22921.  
  22922. If the mouse button is released over an enabled item in a menu belonging to a desk
  22923. accessory, MenuSelect passes the menu ID and item number to the Desk Manager procedure
  22924. SystemMenu for processing, and returns 0 to your application in the high-order word
  22925. of the result.
  22926.  
  22927. Note:  When a menu is pulled down, the bits behind it are stored as a
  22928.        relocatable object in the application heap. If your application
  22929.        has large menus, this can temporarily use up a lot of memory.
  22930.  
  22931. •••Refer to Figure 4.•••
  22932.  
  22933. Figure 4–MenuSelect and MenuKey
  22934.  
  22935. Assembly-language note:  If the global variable MBarEnable is nonzero,
  22936.                          MenuSelect knows that every menu currently in
  22937.                          the menu bar belongs to a desk accessory. (See
  22938.                          the Desk Manager chapter for more information.)
  22939.  
  22940.                          You can store in the global variables MenuHook and
  22941.                          MBarHook the addresses of routines that will be called
  22942.                          during MenuSelect. Both variables are initialized to
  22943.                          0 by InitMenus. The routine whose address is in
  22944.                          MenuHook (if any) will be called repeatedly (with no
  22945.                          parameters) while the mouse button is down. The
  22946.                          routine whose address is in MBarHook (if any) will
  22947.                          be called after the title of the menu is highlighted
  22948.                          and the menu rectangle is calculated, but before the
  22949.                          menu is drawn. (The menu rectangle is the rectangle in
  22950.                          which the menu will be drawn, in global coordinates.)
  22951.                          The routine is passed a pointer to the menu rectangle
  22952.                          on the stack. It should normally return 0 in register
  22953.                          D0; returning 1 will abort MenuSelect.
  22954.  
  22955. If the user chooses an item with a submenu, MenuSelect returns zero, meaning that no
  22956. item was selected. If the user selects an item from a hierarchical menu, the menuID
  22957. of the hierarchical menu and the menuItem of the item chosen are returned, just as
  22958. though the item had been in a regular menu.
  22959.  
  22960. If MenuSelect returns zero, an application may call MenuChoice to determine whether
  22961. the mouse was released over either a disabled menu item or an item with a submenu.
  22962.  
  22963. Note:  The global variable TheMenu contains the ID of the highlighted menu in
  22964.        the menu bar. If an item from a hierarchical menu is chosen, TheMenu
  22965.        contains the ID of the “owner” menu, not the ID of the hierarchical menu.
  22966.  
  22967. æKY mPopUpMsg
  22968. æFp Menus.p
  22969. æC mPopUpMsg = 3; {menu defProc messages - place yourself}
  22970.  
  22971. æKY NewMenu
  22972. æFp Menus.p
  22973. æT FUNCTION
  22974. æTN $A931
  22975. æD FUNCTION NewMenu(menuID: INTEGER;menuTitle: Str255): MenuHandle;
  22976. æDT myVariable := NewMenu(menuID,menuTitle);
  22977. æMM   
  22978. æRI NewMenu function  I-351, P-102, 103
  22979. æC 
  22980. NewMenu allocates space for a new menu with the given menu ID and title, and returns
  22981. a handle to it. It sets up the menu to use the standard menu definition procedure.
  22982. (The menu definition procedure is read into memory if it isn’t already in memory.)
  22983. The new menu (which is created empty) is not installed in the menu list. To use this
  22984. menu, you must first call AppendMenu or AddResMenu to fill it with items, InsertMenu
  22985. to place it in the menu list, and DrawMenuBar to update the menu bar to include the
  22986. new title.
  22987.  
  22988. Application menus should always have positive menu IDs. Negative menu IDs are reserved
  22989. for menus belonging to desk accessories. No menu should ever have a menu ID of 0.
  22990.  
  22991. If you want to set up the title of the Apple menu from your program instead of reading
  22992. it in from a resource file, you can use the constant appleMark (defined by the Font
  22993. Manager as the character code for the apple symbol). For example, you can declare the
  22994. string variable
  22995.  
  22996.   VAR myTitle:  STRING[1];
  22997.  
  22998. and do the following:
  22999.  
  23000.   myTitle := ' ';
  23001.   myTitle[1] := CHR(appleMark)
  23002.  
  23003. To release the memory occupied by a menu that you created with NewMenu, call DisposeMenu.
  23004.  
  23005. æKY noMark
  23006. æFp Menus.p
  23007. æC 
  23008.   { Value indicating item has no mark }
  23009.  
  23010.   noMark          = 0;
  23011.  
  23012. æKY PopUpMenuSelect
  23013. æFp Menus.p
  23014. æT FUNCTION
  23015. æTN $A80B
  23016. æD FUNCTION PopUpMenuSelect(menu: MenuHandle;top: INTEGER;left: INTEGER;
  23017.     popUpItem: INTEGER): LONGINT;
  23018. æDT myVariable := PopUpMenuSelect(menu,top,left,popUpItem);
  23019. æMM 
  23020. æRT 156
  23021. æRI PopUpMenuSelect function  V-241, N156-2
  23022. æC 
  23023. [Macintosh Plus, Macintosh SE, Macintosh II]
  23024.  
  23025. The PopUpMenuSelect routine allows an application to create a pop-up menu anywhere on
  23026. the screen. This menu may be colored like any other menu, and it may have submenus.
  23027. The return value is the same as that for MenuSelect, where the low word is the menu
  23028. item selected, and the high word is the menu ID. Unlike MenuSelect, PopUpMenuSelect
  23029. doesn’t highlight any of the menus in the menu bar, so HiliteMenu(0) doesn’t have to
  23030. be called after completing the chosen task.
  23031.  
  23032. Pop-up menus are typically used for lists of items, for example, fonts. See the
  23033. Macintosh User Interface Guidelines chapter for a description of how to use pop-up
  23034. menus in your application. See MenuSelect for information about the return value when
  23035. the menu chosen is a hierarchical menu.
  23036.  
  23037. TheMenu is a handle to the menu that you want “popped up”. The PopUpItem is typically
  23038. the currently selected item, that is, the last item selected, or the first item if
  23039. nothing was selected. Doing this allows the user to click on a pop-up menu and release
  23040. again quickly, without changing the item selection by mistake. The parameters Top and
  23041. Left define where the top left corner of the PopUpItem is to appear, in global coordinates.
  23042. Typically, these will be the top left coordinates of the pop-up box, so that the menu
  23043. item appears on top of the pop-up box. See Figure 5 for an example.
  23044.  
  23045. •••Refer to Figure 5.•••
  23046.  
  23047. Figure 5–Pop-up Box Parameters
  23048.  
  23049. »Drawing the Pop-Up Box
  23050.  
  23051. Your application is responsible for drawing the pop-up box. A pop-up box is a rectangle
  23052. that is the same height as the menu item, is wide enough to show the currently selected
  23053. item, and has a one-pixel-wide drop shadow.
  23054.  
  23055. The pop-up box must be the same height as a menu item so that when the menu appears,
  23056. the cursor will be in the previously chosen item. If the pop-up box is too tall, the
  23057. user could click once quickly in a pop-up box and unintentionally choose a different
  23058. menu item. The height of a menu item in the system font is the ascent + descent +
  23059. leading.
  23060.  
  23061. The pop-up box has a title to its left. The application is responsible for recognizing
  23062. a mouse-down event in the pop-up box, and highlighting the title to the left of the
  23063. pop-up menu box before calling MenuSelect. Similarly, the application is responsible
  23064. for highlighting the title if the pop-up menu has Command-key equivalents.
  23065.  
  23066. Before calling PopUpMenuSelect, the pop-up menu must be installed in the hierarchical
  23067. portion of the MenuList by passing a value of  –1 as the “beforeID” to InsertMenu.
  23068.  
  23069. The following is a sample psuedocode stub that might be used to track a pop-up menu:
  23070.  
  23071.   if mouse is in popUpMenuRect then  
  23072.       myInvertPopUpTitle();               {invert title of pop-up menu}
  23073.       InsertMenu(popupMenuHandle, -1);    {-1 means hierarchical menu}
  23074.       Result = PopUpMenuSelect(popUpMenuHandle, popUpRect.Top,
  23075.                                popUpRect.Left, lastItemSelected);
  23076.       DeleteMenu(popUpMenuID);
  23077.       myInvertPopUpTitle();               {return pop-up title to normal}
  23078.   endif
  23079.  
  23080. Notice that PopUpMenuSelect’s sole function is to display the pop-up menu and track
  23081. the mouse during a mouse-down event. It is the application’s responsibility to handle
  23082. all other pop-up menu functions, such as drawing the pop-up box, drawing and highlighting
  23083. the title, and changing the entry in the pop-up box after an item has been chosen
  23084. from the pop-up menu. This could all be handled by creating a pop-up menu control
  23085. within the application.
  23086.  
  23087. When calling PopUpMenuSelect, the pop-up menu must be in the MenuList for the duration
  23088. of the call. The code above shows a call the InsertMenu before, and a call to DeleteMenu
  23089. after, the call to PopUpMenuSelect. The InsertMenu must be used at some time before
  23090. the call to PopUpMenuSelect, but it’s not necessary to call DeleteMenu immediately
  23091. afterwards; the pop-up menu may be left in the MenuList if desired.
  23092.  
  23093. Pop-up menu items can have Command-key equivalents. The application must provide
  23094. sufficient visual feedback, normally provided by using MenuKey, by inverting the
  23095. pop-up title.
  23096.  
  23097. æKY SetItem
  23098. æFp Menus.p
  23099. æT PROCEDURE
  23100. æTN $A947
  23101. æD PROCEDURE SetItem(theMenu: MenuHandle;item: INTEGER;itemString: Str255);
  23102. æDT SetItem(theMenu,item,itemString);
  23103. æMM   
  23104. æRI SetItem procedure I-357, P-104, 180
  23105. æC 
  23106. SetItem changes the text of the given menu item to itemString. It doesn’t recognize
  23107. the meta-characters used in AppendMenu; if you include them in itemString, they will
  23108. appear in the text of the menu item. The attributes already in effect for this item—its
  23109. character style, icon, and so on—remain in effect. ItemString may be blank but should
  23110. not be the empty string.
  23111.  
  23112. Note:  It’s good practice to store the text of itemString in a resource
  23113.        file instead of passing it directly.
  23114.  
  23115. Use SetItem to change between the two forms of a toggled command—for example, to
  23116. change “Show Clipboard” to “Hide Clipboard” when the Clipboard is already showing.
  23117.  
  23118. Note:  To avoid confusing the user, don’t capriciously change the text
  23119.        of menu items.
  23120.  
  23121. æKY SetItemCmd
  23122. æFp Menus.p
  23123. æT PROCEDURE
  23124. æTN $A84F
  23125. æD PROCEDURE SetItemCmd(theMenu: MenuHandle;item: INTEGER;cmdChar: CHAR);
  23126. æDT SetItemCmd(theMenu,item,cmdChar);
  23127. æRI SetItemCmd procedure  V-240
  23128. æC 
  23129. [Macintosh Plus, Macintosh SE, Macintosh II]
  23130.  
  23131. The SetItemCmd routine allows the application to attach a submenu to a menu by passing
  23132. the character $1B. You should be careful about arbitrarily adding or removing a
  23133. submenu from a menu item; see the Macintosh User Interface Guidelines chapter for
  23134. recommendations. Notice that SetItemMark can be used to change the ID of the submenu
  23135. that is associated with the menu item.
  23136.  
  23137. Note:  SetItemCmd must never be used to change the Command-key value of a
  23138.        menu item that doesn’t have a submenu; users must always be free to
  23139.        change their Command-key preferences.
  23140.  
  23141. æKY SetItemIcon
  23142. æFp Menus.p
  23143. æT PROCEDURE
  23144. æTN $A940
  23145. æD PROCEDURE SetItemIcon(theMenu: MenuHandle;item: INTEGER;icon: Byte);
  23146. æDT SetItemIcon(theMenu,item,icon);
  23147. æMM   
  23148. æRI SetItemIcon procedure I-359, V-246
  23149. æC 
  23150. Assembly-language note:  The macro you invoke to call SetItemIcon from
  23151.                          assembly language is named _SetItmIcon.
  23152.  
  23153. SetItemIcon associates the given menu item with an icon. It sets the item’s icon
  23154. number to the given value (an integer from 1 to 255). The Menu Manager adds 256 to
  23155. the icon number to get the icon’s resource ID, which it passes to the Resource Manager
  23156. to get the corresponding icon.
  23157.  
  23158. Warning:  If you call the Resource Manager directly to read or store
  23159.           menu icons, be sure to adjust your icon numbers accordingly.
  23160.  
  23161. Menu items initially have no icons unless you specify otherwise (such as with the “^”
  23162. meta-character in a call to AppendMenu).
  23163.  
  23164. The SetItemIcon procedure should never be called for font items that are international
  23165. scripts, unless the intention is to change the script number
  23166. (there should never be any need to do this).
  23167.  
  23168. æKY SetItemMark
  23169. æFp Menus.p
  23170. æT PROCEDURE
  23171. æTN $A944
  23172. æD PROCEDURE SetItemMark(theMenu: MenuHandle;item: INTEGER;markChar: CHAR);
  23173. æDT SetItemMark(theMenu,item,markChar);
  23174. æMM   
  23175. æRI SetItemMark procedure I-359, V-246
  23176. æC 
  23177. Assembly-language note:  The macro you invoke to call SetItemMark from
  23178.                          assembly language is named _SetItmMark.
  23179.  
  23180. SetItemMark marks the given menu item in a more general manner than CheckItem. It
  23181. allows you to place any character in the system font, not just the check mark, to the
  23182. left of the item. The character is passed in the markChar parameter.
  23183.  
  23184. Note:  The Font Manager defines constants for the check mark and other special
  23185.        characters that can’t normally be typed from the keyboard:  the apple
  23186.        symbol, the Command key symbol, and a diamond symbol. See the Font
  23187.        Manager chapter for more information.
  23188.  
  23189. To remove an item’s mark, you can pass the following predefined constant in the
  23190. markChar parameter:
  23191.  
  23192. CONST noMark = 0;
  23193.  
  23194. The SetItemMark procedure allows the application to change the submenu associated
  23195. with a menu item.
  23196.  
  23197. æKY SetItemStyle
  23198. æFp Menus.p
  23199. æT PROCEDURE
  23200. æTN $A942
  23201. æD PROCEDURE SetItemStyle(theMenu: MenuHandle;item: INTEGER;chStyle: Style);
  23202. æDT SetItemStyle(theMenu,item,chStyle);
  23203. æMM   
  23204. æRI SetItemStyle procedure I-360
  23205. æC 
  23206. Assembly-language note:  The macro you invoke to call SetItemStyle from
  23207.                          assembly language is named _SetItmStyle.
  23208.  
  23209. SetItemStyle changes the character style of the given menu item to chStyle. For
  23210. example:
  23211.  
  23212.   SetItemStyle(thisMenu,1,[bold,italic])    {bold and italic}
  23213.  
  23214. Menu items are initially in the plain character style unless you specify otherwise
  23215. (such as with the “<” meta-character in a call to AppendMenu).
  23216.  
  23217. æKY SetMCEntries
  23218. æFp Menus.p
  23219. æT PROCEDURE
  23220. æTN $AA65
  23221. æD PROCEDURE SetMCEntries(numEntries: INTEGER;menuCEntries: MCTablePtr);
  23222. æDT SetMCEntries(numEntries,menuCEntries);
  23223. æMM   
  23224. æRI SetMCEntries procedure  V-239
  23225. æC 
  23226. [Macintosh II]
  23227.  
  23228. The SetMCEntries procedure takes a pointer to an array of color information records.
  23229. The array may be of any size, so it’s necessary to also pass the number of entries in
  23230. the array.
  23231.  
  23232. The ID and Item of each entry in the color information record array are checked to
  23233. see if the entry already exists in the menu color information table. If it exists,
  23234. the information in the entry is used to update the entry in the color table. If the
  23235. entry doesn’t exist in the color information table, the entry is added to the table.
  23236.  
  23237. Warning:  SetMCEntries makes memory management calls that may move or purge
  23238.           memory; therefore the array menuCEntries should be nonrelocatable
  23239.           for the duration of this call.
  23240.  
  23241. æKY SetMCInfo
  23242. æFp Menus.p
  23243. æT PROCEDURE
  23244. æTN $AA62
  23245. æD PROCEDURE SetMCInfo(menuCTbl: MCTableHandle);
  23246. æDT SetMCInfo(menuCTbl);
  23247. æMM   
  23248. æRI SetMCInfo procedure  V-239
  23249. æC 
  23250. [Macintosh II]
  23251.  
  23252. The SetMCInfo routine copies the given menu color information table to the current
  23253. menu color information table. It first disposes of the current menu color information
  23254. table, so your application shouldn’t explicitly dispose the current table. If the
  23255. copy fails, the global variable MemErr contains the error code, and the procedure
  23256. doesn’t dispose the current menu color information table. Applications should call
  23257. the MemError function to determine if this call failed.
  23258.  
  23259. You can use this procedure to restore a menu color information table previously saved
  23260. by GetMCInfo. Be sure to call DrawMenuBar to update the menu bar if a new menu bar
  23261. color or menu title colors have been specified.
  23262.  
  23263. æKY SetMenuBar
  23264. æFp Menus.p
  23265. æT PROCEDURE
  23266. æTN $A93C
  23267. æD PROCEDURE SetMenuBar(menuList: Handle);
  23268. æDT SetMenuBar(menuList);
  23269. æRT 180
  23270. æRI SetMenuBar procedure I-355, P-102, 180
  23271. æC 
  23272. SetMenuBar copies the given menu list to the current menu list. You can use this
  23273. procedure to restore a menu list previously saved by GetMenuBar, or pass it a handle
  23274. returned by GetNewMBar. Be sure to call DrawMenuBar to update the menu bar.
  23275.  
  23276. æKY SetMenuFlash
  23277. æFp Menus.p
  23278. æT PROCEDURE
  23279. æTN $A94A
  23280. æD PROCEDURE SetMenuFlash(count: INTEGER);
  23281. æDT SetMenuFlash(count);
  23282. æRI SetMenuFlash procedure I-361
  23283. æC 
  23284. Assembly-language note:  The macro you invoke to call SetMenuFlash from
  23285.                          assembly language is named _SetMFlash.
  23286.  
  23287. When the mouse button is released over an enabled menu item, the item blinks briefly
  23288. to confirm the choice. Normally, your application shouldn’t be concerned with this
  23289. blinking; the user sets it with the Control Panel desk accessory. If you’re writing a
  23290. desk accessory like the Control Panel, though, SetMenuFlash allows you to control the
  23291. duration of the blinking. The count parameter is the number of times menu items will
  23292. blink; it’s initially 3 if the user hasn’t changed it. A count of 0 disables blinking.
  23293. Values greater than 3 can be annoyingly slow.
  23294.  
  23295. Note:  Items in both standard and nonstandard menus blink when chosen. The
  23296.        appearance of the blinking for a nonstandard menu depends on the menu
  23297.        definition procedure, as described in “Defining Your Own Menus”.
  23298.  
  23299. Assembly-language note:  The current count is stored in the global
  23300.                          variable MenuFlash.
  23301.  
  23302. æKY textMenuProc
  23303. æFp Menus.p
  23304. æC 
  23305.   { Resource ID of standard menu definition procedure }
  23306.  
  23307. textMenuProc = 0;
  23308.  
  23309.  
  23310. æKY Notification.p
  23311. æKL NMInstall
  23312. NMRemove
  23313.  
  23314. NMRec
  23315. nmType
  23316.  
  23317. æKY NMInstall
  23318. æFp Notification.p
  23319. æT FUNCTION
  23320. æTN $A05E
  23321. æD FUNCTION NMInstall(nmReqPtr: QElemPtr): OSErr;
  23322. æDT myVariable := NMInstall(nmReqPtr);
  23323. æRT 184
  23324.  
  23325.  
  23326. æKY NMRec
  23327. æFp Notification.p
  23328. æT RECORD
  23329. æC NMRec = RECORD
  23330.    qLink: QElemPtr;        {next queue entry}
  23331.    qType: INTEGER;         {queue type -- ORD(nmType) = 8}
  23332.    nmFlags: INTEGER;       {reserved}
  23333.    nmPrivate: LONGINT;     {reserved}
  23334.    nmReserved: INTEGER;    {reserved}
  23335.    nmMark: INTEGER;        {item to mark in Apple menu}
  23336.    nmSIcon: Handle;        {handle to small icon}
  23337.    nmSound: Handle;        {handle to sound record}
  23338.    nmStr: StringPtr;       {string to appear in alert}
  23339.    nmResp: ProcPtr;        {pointer to response routine}
  23340.    nmRefCon: LONGINT;      {for application use}
  23341.    END;
  23342.  
  23343. æKY NMRemove
  23344. æFp Notification.p
  23345. æT FUNCTION
  23346. æTN $A05F
  23347. æD FUNCTION NMRemove(nmReqPtr: QElemPtr): OSErr;
  23348. æDT myVariable := NMRemove(nmReqPtr);
  23349. æRT 184
  23350.  
  23351.  
  23352. æKY nmType
  23353. æFp Notification.p
  23354. æC nmType = 8;
  23355.  
  23356.  
  23357. æKY OSEvents.p
  23358. æKL FlushEvents
  23359. GetEvQHdr
  23360. GetOSEvent
  23361. OSEventAvail
  23362. PostEvent
  23363. PPostEvent
  23364. SetEventMask
  23365.  
  23366. æKY FlushEvents
  23367. æFp OSEvents.p
  23368. æT PROCEDURE
  23369. æTN $A032
  23370. æD PROCEDURE FlushEvents(whichMask: INTEGER;stopMask: INTEGER);
  23371. æDT FlushEvents(whichMask,stopMask);
  23372. æRI FlushEvents procedure  II-69, P-31, 170
  23373. æC 
  23374. Trap macro  _FlushEvents
  23375. On entry    D0:    low-order word:    eventMask
  23376.                    high-order word:   stopMask
  23377. On exit     D0:    0 or event code (word)
  23378.  
  23379. FlushEvents removes events from the event queue as specified by the given event
  23380. masks. It removes all events of the type or types specified by eventMask, up to but
  23381. not including the first event of any type specified by stopMask; if the event queue
  23382. doesn’t contain any events of the types specified by eventMask, it does nothing. To
  23383. remove all events specified by eventMask, use a stopMask value of 0.
  23384.  
  23385. At the beginning of your application, it’s usually a good idea to call FlushEvents(everyEvent,0)
  23386. to empty the event queue of any stray events that may have been left lying around,
  23387. such as unprocessed keystrokes typed to the Finder.
  23388.  
  23389. Assembly-language note:  On exit from this routine, D0 contains 0 if all
  23390.                          events were removed from the queue or, if not, an
  23391.                          event code specifying the type of event that caused
  23392.                          the removal process to stop.
  23393.  
  23394. æKY GetEvQHdr
  23395. æFp OSEvents.p
  23396. æT FUNCTION
  23397. æD FUNCTION GetEvQHdr: QHdrPtr;
  23398. æDT myVariable := GetEvQHdr;
  23399. æRI GetEvQHdr function  II-71
  23400. æC  
  23401. [Not in ROM]
  23402.  
  23403. GetEvQHdr returns a pointer to the header of the event queue.
  23404.  
  23405. Assembly-language note:  The global variable EventQueue contains the
  23406.                          header of the event queue.
  23407.  
  23408. æKY GetOSEvent
  23409. æFp OSEvents.p
  23410. æT FUNCTION
  23411. æTN $A031
  23412. æD FUNCTION GetOSEvent(mask: INTEGER;VAR theEvent: EventRecord): BOOLEAN;
  23413. æDT myVariable := GetOSEvent(mask,theEvent);
  23414. æRT 85
  23415. æRI GetOSEvent function  II-69, N85-1
  23416. æC 
  23417. Trap macro  _GetOSEvent
  23418. On entry    A0:  pointer to event record theEvent
  23419.             D0:  eventMask (word)
  23420. On exit     D0:  0 if non-null event returned, or –1 if null event
  23421.                  returned (byte)
  23422.  
  23423. GetOSEvent returns the next available event of a specified type or types and removes
  23424. it from the event queue. The event is returned as the value of the parameter theEvent.
  23425. The eventMask parameter specifies which event types are of interest. GetOSEvent will
  23426. return the next available event of any type designated by the mask. If no event of
  23427. any of the designated types is available, GetOSEvent returns a null event and a
  23428. function result of FALSE; otherwise it returns TRUE.
  23429.  
  23430. Note:  Unlike the Toolbox Event Manager function GetNextEvent, GetOSEvent
  23431.        doesn’t call the Desk Manager to see whether the system wants to
  23432.        intercept and respond to the event; nor does it perform GetNextEvent’s
  23433.        processing of the alarm and Command-Shift-number combinations.
  23434.  
  23435. æKY OSEventAvail
  23436. æFp OSEvents.p
  23437. æT FUNCTION
  23438. æTN $A030
  23439. æD FUNCTION OSEventAvail(mask: INTEGER;VAR theEvent: EventRecord): BOOLEAN;
  23440. æDT myVariable := OSEventAvail(mask,theEvent);
  23441. æRI OSEventAvail function II-70
  23442. æC 
  23443. Trap macro  _OSEventAvail
  23444. On entry    A0:  pointer to event record theEvent
  23445.             D0:  eventMask (word)
  23446. On exit     D0:  0 if non-null event returned, or –1 if null event
  23447.                  returned (byte)
  23448.  
  23449. OSEventAvail works exactly the same as GetOSEvent (above) except that it
  23450. doesn’t remove the event from the event queue.
  23451.  
  23452. Note:  An event returned by OSEventAvail will not be accessible later if
  23453.        in the meantime the queue becomes full and the event is discarded
  23454.        from it; since the events discarded are always the oldest ones in
  23455.        the queue, however, this will happen only in an unusually busy
  23456.        environment.
  23457.  
  23458. æKY PostEvent
  23459. æFp OSEvents.p
  23460. æT FUNCTION
  23461. æTN $A02F
  23462. æD FUNCTION PostEvent(eventNum: INTEGER;eventMsg: LONGINT): OSErr;
  23463. æDT myVariable := PostEvent(eventNum,eventMsg);
  23464. æRI PostEvent function II-68
  23465. æC 
  23466. Trap macro  _PostEvent
  23467. On entry    A0:  eventCode (word)
  23468.             D0:  eventMsg (long word)
  23469. On exit     D0:  result code (word)
  23470.  
  23471. PostEvent places in the event queue an event of the type designated by eventCode,
  23472. with the event message specified by eventMsg and with the current time, mouse location,
  23473. and state of the modifier keys and mouse button. It returns a result code (of type
  23474. OSErr, defined as INTEGER in the Operating System Utilities) equal to one of the
  23475. following predefined constants:
  23476.  
  23477. CONST  noErr        = 0;    {no error (event posted)}
  23478.        evtNotEnb    = 1;    {event type not designated in system event mask}
  23479.  
  23480. Warning:  Be very careful when posting any events other than your own
  23481.           application-defined events into the queue; attempting to post an
  23482.           activate or update event, for example, will interfere with the
  23483.           internal operation of the Toolbox Event Manager, since such events
  23484.           aren’t normally placed in the queue at all.
  23485.  
  23486. Warning:  If you use PostEvent to repost an event, remember that the event
  23487.           time, location, and state of the modifier keys and mouse button
  23488.           will all be changed from their values when the event was originally
  23489.           posted, possibly altering the meaning of the event.
  23490.  
  23491. æKY PPostEvent
  23492. æFp OSEvents.p
  23493. æT FUNCTION
  23494. æTN $A12F
  23495. æD FUNCTION PPostEvent(eventCode: INTEGER;eventMsg: LONGINT;VAR qEl: EvQElPtr): OSErr;
  23496. æDT myVariable := PPostEvent(eventCode,eventMsg,qEl);
  23497. æC 
  23498. Trap macro  _PPostEvent
  23499. On entry    A0:  eventCode (word)
  23500.             D0:  eventMsg (long word)
  23501. On exit     A0:  pointer to event queue entry
  23502.  
  23503. PPostEvent is identical to PostEvent except that it returns a pointer to the created
  23504. queue entry.
  23505.  
  23506. æKY SetEventMask
  23507. æFp OSEvents.p
  23508. æT PROCEDURE
  23509. æD PROCEDURE SetEventMask(theMask: INTEGER);
  23510. æDT SetEventMask(theMask);
  23511. æRT 202
  23512. æRI SetEventMask procedure II-70
  23513. æC 
  23514. [Not in ROM]
  23515.  
  23516. SetEventMask sets the system event mask to the specified event mask. The Operating
  23517. System Event Manager will post only those event types that correspond to bits set in
  23518. the mask. (As usual, it will not post activate and update events, which are generated
  23519. by the Window Manager and not stored in the event queue.) The system event mask is
  23520. initially set to post all except key-up events.
  23521.  
  23522. Warning:  Because desk accessories may rely on receiving certain types of
  23523.           events, your application shouldn’t set the system event mask to
  23524.           prevent any additional types (besides key-up) from being posted.
  23525.           You should use SetEventMask only to enable key-up events in the
  23526.           unusual case that your application needs to respond to them.
  23527.  
  23528. Assembly-language note:  The system event mask is available to assembly-
  23529.                          language programmers in the global variable SysEvtMask.
  23530.  
  23531. æKY OSUtils.p
  23532. æKL Date2Secs
  23533. Delay
  23534. Dequeue
  23535. DTInstall
  23536. Enqueue
  23537. Environs
  23538. EqualString
  23539. FlushDataCache
  23540. FlushInstructionCache
  23541. GetDateTime
  23542. GetMMUMode
  23543. GetSysPPtr
  23544. GetTime
  23545. GetTrapAddress
  23546. HandAndHand
  23547. HandToHand
  23548. InitUtil
  23549. KeyTrans
  23550. NGetTrapAddress
  23551. NSetTrapAddress
  23552. PtrAndHand
  23553. PtrToHand
  23554. PtrToXHand
  23555. ReadDateTime
  23556. RelString
  23557. Restart
  23558. RestoreA5
  23559. Secs2Date
  23560. SetA5
  23561. SetCurrentA5
  23562. SetDateTime
  23563. SetTime
  23564. SetTrapAddress
  23565. SetUpA5
  23566. SwapDataCache
  23567. SwapInstructionCache
  23568. SwapMMUMode
  23569. SysBeep
  23570. SysEnvirons
  23571. UprString
  23572. WriteParam
  23573.  
  23574. curSysEnvVers
  23575. DateTimeRec
  23576. DrvQEl
  23577. DrvQElPtr
  23578. drvQType
  23579. dummyType
  23580. env512KE
  23581. env68000
  23582. env68010
  23583. env68020
  23584. env68030
  23585. envAExtendKbd
  23586. envCPUUnknown
  23587. envMac
  23588. envMacAndPad
  23589. envMachUnknown
  23590. envMacKbd
  23591. envMacPlus
  23592. envMacPlusKbd
  23593. envSE
  23594. envSE30
  23595. envStandADBKbd
  23596. envUnknownKbd
  23597. envXL
  23598. EvQEl
  23599. EvQElPtr
  23600. evType
  23601. false32b
  23602. fsQType
  23603. ioQType
  23604. macMachine
  23605. macXLMachine
  23606. OSTrap
  23607. ParamBlockRec
  23608. ParmBlkPtr
  23609. QElem
  23610. QElemPtr
  23611. QHdr
  23612. QHdrPtr
  23613. QTypes
  23614. sortsAfter
  23615. sortsBefore
  23616. sortsEqual
  23617. SysEnvRec
  23618. SysParmType
  23619. SysPPtr
  23620. ToolTrap
  23621. TrapType
  23622. true32b
  23623. useAsync
  23624. useATalk
  23625. useExtClk
  23626. useFree
  23627. useMIDI
  23628. vType
  23629.  
  23630. æKY ParmBlkPtr,ParamBlockRec
  23631. æFp OSUtils.p
  23632. æT TYPE
  23633. æC ParmBlkPtr = ^ParamBlockRec;
  23634. ParamBlockRec = RECORD
  23635.    qLink: QElemPtr;
  23636.    qType: INTEGER;
  23637.    ioTrap: INTEGER;
  23638.    ioCmdAddr: Ptr;
  23639.    ioCompletion: ProcPtr;
  23640.    ioResult: OSErr;
  23641.    ioNamePtr: StringPtr;
  23642.    ioVRefNum: INTEGER;
  23643.    CASE ParamBlkType OF
  23644.      IOParam:
  23645.        (ioRefNum: INTEGER;
  23646.        ioVersNum: SignedByte;
  23647.        ioPermssn: SignedByte;
  23648.        ioMisc: Ptr;
  23649.        ioBuffer: Ptr;
  23650.        ioReqCount: LONGINT;
  23651.        ioActCount: LONGINT;
  23652.        ioPosMode: INTEGER;
  23653.        ioPosOffset: LONGINT);
  23654.      FileParam:
  23655.        (ioFRefNum: INTEGER;
  23656.        ioFVersNum: SignedByte;
  23657.        filler1: SignedByte;
  23658.        ioFDirIndex: INTEGER;
  23659.        ioFlAttrib: SignedByte;
  23660.        ioFlVersNum: SignedByte;
  23661.        ioFlFndrInfo: FInfo;
  23662.        ioFlNum: LONGINT;
  23663.        ioFlStBlk: INTEGER;
  23664.        ioFlLgLen: LONGINT;
  23665.        ioFlPyLen: LONGINT;
  23666.        ioFlRStBlk: INTEGER;
  23667.        ioFlRLgLen: LONGINT;
  23668.        ioFlRPyLen: LONGINT;
  23669.        ioFlCrDat: LONGINT;
  23670.        ioFlMdDat: LONGINT);
  23671.      VolumeParam:
  23672.        (filler2: LONGINT;
  23673.        ioVolIndex: INTEGER;
  23674.        ioVCrDate: LONGINT;
  23675.        ioVLsBkUp: LONGINT;
  23676.        ioVAtrb: INTEGER;
  23677.        ioVNmFls: INTEGER;
  23678.        ioVDirSt: INTEGER;
  23679.        ioVBlLn: INTEGER;
  23680.        ioVNmAlBlks: INTEGER;
  23681.        ioVAlBlkSiz: LONGINT;
  23682.        ioVClpSiz: LONGINT;
  23683.        ioAlBlSt: INTEGER;
  23684.        ioVNxtFNum: LONGINT;
  23685.        ioVFrBlk: INTEGER);
  23686.      CntrlParam:
  23687.        (ioCRefNum: INTEGER;
  23688.        csCode: INTEGER;
  23689.        csParam: ARRAY [0..10] OF INTEGER);
  23690.      SlotDevParam:
  23691.        (filler3: LONGINT;
  23692.        ioMix: Ptr;
  23693.        ioFlags: INTEGER;
  23694.        ioSlot: SignedByte;
  23695.        ioID: SignedByte);
  23696.      MultiDevParam:
  23697.        (filler4: LONGINT;
  23698.        ioMMix: Ptr;
  23699.        ioMFlags: INTEGER;
  23700.        ioSEBlkPtr: Ptr);
  23701.    END;
  23702.  
  23703. æKY DrvQEl,DrvQElPtr
  23704. æFp OSUtils.p
  23705. æT TYPE
  23706. æC DrvQElPtr = ^DrvQEl;
  23707. DrvQEl = RECORD
  23708.    qLink: QElemPtr;
  23709.    qType: INTEGER;
  23710.    dQDrive: INTEGER;
  23711.    dQRefNum: INTEGER;
  23712.    dQFSID: INTEGER;
  23713.    dQDrvSz: INTEGER;
  23714.    dQDrvSz2: INTEGER;
  23715.    END;
  23716. »The Drive Queue
  23717.  
  23718. •••Refer to Technical Note #36:•••
  23719.  
  23720. Disk drives connected to the Macintosh are opened when the system starts up, and
  23721. information describing each is placed in the drive queue. This is a standard Operating
  23722. System queue, and each entry in it has the following structure:
  23723.  
  23724. TYPE DrvQEl =  RECORD
  23725.                  qLink:     QElemPtr;   {next queue entry}
  23726.                  qType:     INTEGER;    {queue type}
  23727.                  dQDrive:   INTEGER;    {drive number}
  23728.                  dQRefNum:  INTEGER;    {driver reference number}
  23729.                  dQFSID:    INTEGER;    {file-system identifier}
  23730.                  dQDrvSz:   INTEGER;    {number of logical blocks on drive}
  23731.                  dQDrvSz2:  INTEGER;    {additional field to handle large }
  23732.                                         { drive size}
  23733.                END;
  23734.  
  23735. QLink points to the next entry in the queue. If qType is 0, this means the number of
  23736. logical blocks on the drive is contained in the dQDrvSz field alone. If qType is 1,
  23737. both dQDrvSz and dQDrvSz2 are used to store the number of blocks; dqDrvSz2 contains
  23738. the high-order word of this number and dQDrvSz contains the low-order word.
  23739.  
  23740. DQDrive contains the drive number of the drive on which the volume is mounted; dQRefNum
  23741. contains the driver reference number of the driver controlling the device on which
  23742. the volume is mounted. DQFSID identifies the file system handling the volume in the
  23743. drive; it’s 0 for volumes handled by the File Manager, and nonzero for volumes handled
  23744. by other file systems.
  23745.  
  23746. Four bytes of flags precede each drive queue entry; they’re accessible only from
  23747. assembly language.
  23748.  
  23749. Assembly-language note:  These bytes contain the following:
  23750.  
  23751.                            Byte    Contents
  23752.                            0       Bit 7=1 if volume is locked
  23753.                            1       0 if no disk in drive; 1 or 2 if disk
  23754.                                    in drive; 8 if nonejectable disk in drive;
  23755.                                    $FC-$FF if disk was ejected within last 1.5
  23756.                                    seconds; $48 if disk in drive is
  23757.                                    nonejectable but driver wants a call
  23758.                            2       Used internally during system startup
  23759.                            3       Bit 7=0 if disk is single-sided
  23760.  
  23761. You can get a pointer to the header of the drive queue by calling the File Manager
  23762. function GetDrvQHdr.
  23763.  
  23764. æKY EvQEl,EvQElPtr
  23765. æFp OSUtils.p
  23766. æT TYPE
  23767. æC EvQElPtr = ^EvQEl;
  23768. EvQEl = RECORD
  23769.    qLink: QElemPtr;
  23770.    qType: INTEGER;
  23771.    evtQWhat: INTEGER;      {this part is identical to the EventRecord as...}
  23772.    evtQMessage: LONGINT;   {defined in ToolIntf}
  23773.    evtQWhen: LONGINT;
  23774.    evtQWhere: Point;
  23775.    evtQModifiers: INTEGER;
  23776.    END;
  23777.  
  23778. »STRUCTURE OF THE EVENT QUEUE
  23779. _______________________________________________________________________________
  23780.  
  23781. The event queue is a standard Macintosh Operating System queue, as described in the
  23782. Operating System Utilities chapter. Most programmers will never need to access the
  23783. event queue directly; some advanced programmers, though, may need to do so for special
  23784. purposes.
  23785.  
  23786. Each entry in the event queue contains information about an event:
  23787.  
  23788. TYPE  EvQEl = RECORD
  23789.                 qLink:          QElemPtr;  {next queue entry}
  23790.                 qType:          INTEGER;   {queue type}
  23791.                 evtQWhat:       INTEGER;   {event code}
  23792.                 evtQMessage:    LONGINT;   {event message}
  23793.                 evtQWhen:       LONGINT;   {ticks since startup}
  23794.                 evtQWhere:      Point;     {mouse location}
  23795.                 evtQModifiers:  INTEGER    {modifier flags}
  23796.               END;
  23797.  
  23798. QLink points to the next entry in the queue, and qType indicates the queue type,
  23799. which must be ORD(evType). The remaining five fields of the event queue entry contain
  23800. exactly the same information about the event as do the fields of the event record for
  23801. that event; see the Toolbox Event Manager chapter for a detailed description of the
  23802. contents of these fields.
  23803.  
  23804. You can get a pointer to the header of the event queue by calling the Operating
  23805. System Event Manager function GetEvQHdr.
  23806.  
  23807. æKY QElem,QElemPtr
  23808. æFp OSUtils.p
  23809. æT TYPE
  23810. æC QElemPtr = ^QElem;
  23811. QElem = RECORD
  23812.    CASE QTypes OF
  23813.      vType:
  23814.        (vblQElem: VBLTask);        {vertical blanking}
  23815.      ioQType:
  23816.        (ioQElem: ParamBlockRec);   {I/O parameter block}
  23817.      drvQType:
  23818.        (drvQElem: DrvQEl);         {drive}
  23819.      evType:
  23820.        (evQElem: EvQEl);           {event}
  23821.      fsQType:
  23822.        (vcbQElem: VCB);            {volume control block}
  23823.    END;
  23824. _______________________________________________________________________________
  23825.  
  23826. »OPERATING SYSTEM QUEUES
  23827. _______________________________________________________________________________
  23828.  
  23829. Some of the information used by the Operating System is stored in data structures
  23830. called queues. A queue is a list of identically structured entries linked together by
  23831. pointers. Queues are used to keep track of VBL tasks, I/O requests, events, mounted
  23832. volumes, and disk drives (or other block-formatted devices).
  23833.  
  23834. A standard Operating System queue has a header with the following structure:
  23835.  
  23836. TYPE  QHdr = RECORD
  23837.                qFlags:    INTEGER;    {queue flags}
  23838.                qHead:    QElemPtr;    {first queue entry}
  23839.                qTail:    QElemPtr    {last queue entry}
  23840.              END;
  23841.  
  23842.       QHdrPtr = ^QHdr;
  23843.  
  23844. QFlags contains information (usually flags) that’s different for each queue type.
  23845. QHead points to the first entry in the queue, and qTail points to the last entry in
  23846. the queue. The entries within each type of queue are different; the Operating System
  23847. uses the following variant record to access them:
  23848.  
  23849. TYPE  QTypes = (dummyType,
  23850.                 vType,       {vertical retrace queue type}
  23851.                 ioQType,     {file I/O or driver I/O queue type}
  23852.                 drvQType,    {drive queue type}
  23853.                 evType,      {event queue type}
  23854.                 fsQType);    {volume-control-block queue type}
  23855.       QElem  = RECORD
  23856.                 CASE QTypes OF
  23857.                   vType:     (vblQElem:  VBLTask);
  23858.                   ioQType:   (ioQElem:  ParamBlockRec);
  23859.                   drvQType:  (drvQElem:  DrvQEl);
  23860.                   evType:    (evQElem:  EvQEl);
  23861.                   fsQType:   (vcbQElem:  VCB)
  23862.                END;
  23863.  
  23864.       QElemPtr = ^QElem;
  23865.  
  23866. All entries in queues, regardless of the queue type, begin with four bytes of flags
  23867. followed by a pointer to the next queue entry. The entries are linked through these
  23868. pointers; each one points to the pointer field in the next entry. In Pascal, the data
  23869. type of the pointer is QElemPtr, and the data type of the entry begins with the
  23870. pointer field. Consequently, the flag bytes are inaccessible from Pascal.
  23871.  
  23872. Following the pointer to the next entry, each entry contains an integer designating
  23873. the queue type (for example, ORD(evType) for the event queue). The exact structure of
  23874. the rest of the entry depends on the type of queue; for more information, see the
  23875. chapter that discusses that queue in detail.
  23876.  
  23877. æKY QHdr,QHdrPtr
  23878. æFp OSUtils.p
  23879. æT TYPE
  23880. æC QHdrPtr = ^QHdr;
  23881. QHdr = RECORD
  23882.    qFlags: INTEGER;
  23883.    qHead: QElemPtr;
  23884.    qTail: QElemPtr;
  23885.    END;
  23886. _______________________________________________________________________________
  23887.  
  23888. »OPERATING SYSTEM QUEUES
  23889. _______________________________________________________________________________
  23890.  
  23891. Some of the information used by the Operating System is stored in data structures
  23892. called queues. A queue is a list of identically structured entries linked together by
  23893. pointers. Queues are used to keep track of VBL tasks, I/O requests, events, mounted
  23894. volumes, and disk drives (or other block-formatted devices).
  23895.  
  23896. A standard Operating System queue has a header with the following structure:
  23897.  
  23898. TYPE  QHdr = RECORD
  23899.                qFlags:    INTEGER;    {queue flags}
  23900.                qHead:    QElemPtr;    {first queue entry}
  23901.                qTail:    QElemPtr    {last queue entry}
  23902.              END;
  23903.  
  23904.       QHdrPtr = ^QHdr;
  23905.  
  23906. QFlags contains information (usually flags) that’s different for each queue type.
  23907. QHead points to the first entry in the queue, and qTail points to the last entry in
  23908. the queue. The entries within each type of queue are different; the Operating System
  23909. uses the following variant record to access them:
  23910.  
  23911. TYPE  QTypes = (dummyType,
  23912.                 vType,       {vertical retrace queue type}
  23913.                 ioQType,     {file I/O or driver I/O queue type}
  23914.                 drvQType,    {drive queue type}
  23915.                 evType,      {event queue type}
  23916.                 fsQType);    {volume-control-block queue type}
  23917.       QElem  = RECORD
  23918.                 CASE QTypes OF
  23919.                   vType:     (vblQElem:  VBLTask);
  23920.                   ioQType:   (ioQElem:  ParamBlockRec);
  23921.                   drvQType:  (drvQElem:  DrvQEl);
  23922.                   evType:    (evQElem:  EvQEl);
  23923.                   fsQType:   (vcbQElem:  VCB)
  23924.                END;
  23925.  
  23926.       QElemPtr = ^QElem;
  23927.  
  23928. All entries in queues, regardless of the queue type, begin with four bytes of flags
  23929. followed by a pointer to the next queue entry. The entries are linked through these
  23930. pointers; each one points to the pointer field in the next entry. In Pascal, the data
  23931. type of the pointer is QElemPtr, and the data type of the entry begins with the
  23932. pointer field. Consequently, the flag bytes are inaccessible from Pascal.
  23933.  
  23934. Following the pointer to the next entry, each entry contains an integer designating
  23935. the queue type (for example, ORD(evType) for the event queue). The exact structure of
  23936. the rest of the entry depends on the type of queue; for more information, see the
  23937. chapter that discusses that queue in detail.
  23938.  
  23939. æKY SysParmType,SysPPtr
  23940. æFp OSUtils.p
  23941. æT TYPE
  23942. æC SysPPtr = ^SysParmType;
  23943. SysParmType = PACKED RECORD
  23944.    valid: Byte;
  23945.    aTalkA: Byte;
  23946.    aTalkB: Byte;
  23947.    config: Byte;
  23948.    portA: INTEGER;
  23949.    portB: INTEGER;
  23950.    alarm: LONGINT;
  23951.    font: INTEGER;
  23952.    kbdPrint: INTEGER;
  23953.    volClik: INTEGER;
  23954.    misc: INTEGER;
  23955.    END;
  23956. _______________________________________________________________________________
  23957.  
  23958. »PARAMETER RAM
  23959. _______________________________________________________________________________
  23960.  
  23961. Various settings, such as those specified by the user by means of the Control Panel
  23962. desk accessory, need to be preserved when the Macintosh is off so they will still be
  23963. present at the next system startup. This information is kept in parameter RAM, 20
  23964. bytes that are stored in the clock chip together with the current date and time
  23965. setting. The clock chip is powered by a battery when the system is off, thereby
  23966. preserving all the settings stored in it.
  23967.  
  23968. You may find it necessary to read the values in parameter RAM or even change them
  23969. (for example, if you create a desk accessory like the Control Panel). Since the clock
  23970. chip itself is difficult to access, its contents are copied into low memory at system
  23971. startup. You read and change parameter RAM through this low-memory copy.
  23972.  
  23973. Note:  Certain values from parameter RAM are used so frequently that special
  23974.        routines have been designed to return them (for example, the Toolbox
  23975.        Event Manager function GetDblTime). These routines are discussed in
  23976.        other chapters where appropriate.
  23977.  
  23978. Assembly-language note:  The low-memory copy of parameter RAM begins at the
  23979.                          address SysParam; the various portions of the copy
  23980.                          can be accessed through individual global variables,
  23981.                          listed in the summary at the end of this chapter.
  23982.                          Some of these are copied into other global variables
  23983.                          at system startup for even easier access; for example,
  23984.                          the auto-key threshold and rate, which are contained
  23985.                          in the variable SPKbd in the copy of parameter RAM,
  23986.                          are copied into the variables KeyThresh and
  23987.                          KeyRepThresh. Each such variable is discussed in the
  23988.                          appropriate chapter.
  23989.  
  23990. The date and time setting is also copied at system startup from the clock chip into
  23991. its own low-memory location. It’s stored as a number of seconds since midnight,
  23992. January 1, 1904, and is updated every second. The maximum value, $FFFFFFFF, corresponds
  23993. to 6:28:15 AM, February 6, 2040; after that, it wraps around to midnight, January 1,
  23994. 1904.
  23995.  
  23996. Assembly-language note:  The low-memory location containing the date and
  23997.                          time is the global variable Time.
  23998.  
  23999. The structure of parameter RAM is represented by the following data type:
  24000.  
  24001. TYPE  SysParmType = RECORD
  24002.                       valid:     Byte;     {validity status}
  24003.                       aTalkA:    Byte;     {AppleTalk node ID hint for modem }
  24004.                                            { port}
  24005.                       aTalkB:    Byte;     {AppleTalk node ID hint for printer }
  24006.                                            { port}
  24007.                       config:    Byte;     {use types for serial ports}
  24008.                       portA:     INTEGER;  {modem port configuration}
  24009.                       portB:     INTEGER;  {printer port configuration}
  24010.                       alarm:     LONGINT;  {alarm setting}
  24011.                       font:      INTEGER;  {application font number minus 1}
  24012.                       kbdPrint:  INTEGER;  {auto-key settings, printer }
  24013.                                            { connection}
  24014.                       volClik:   INTEGER;  {speaker volume, double-click, }
  24015.                                            { caret blink}
  24016.                       misc:      INTEGER   {mouse scaling, startup disk, }
  24017.                                            { menu blink}
  24018.                     END;
  24019.  
  24020.       SysPPtr = ^SysParmType;
  24021.  
  24022. The valid field contains the validity status of the clock chip:  Whenever you successfully
  24023. write to the clock chip, $A8 is stored in this byte. The validity status is examined
  24024. when the clock chip is read at system startup. It won’t be $A8 if a hardware problem
  24025. prevented the values from being written; in this case, the low-memory copy of parameter
  24026. RAM is set to the default values shown in the table below, and these values are then
  24027. written to the clock chip itself. (The meanings of the parameters are explained below
  24028. in the descriptions of the various fields.)
  24029.  
  24030.   Parameter                          Default value
  24031.  
  24032.   Validity status                    $A8
  24033.   Node ID hint for modem port        0
  24034.   Node ID hint for printer port      0
  24035.   Use types for serial ports         0 (both ports)
  24036.   Modem port configuration           9600 baud, 8 data bits, 2 stop bits,
  24037.                                      no parity
  24038.   Printer port configuration         Same as for modem port
  24039.   Alarm setting                      0 (midnight, January 1, 1904)
  24040.   Application font number minus 1    2 (Geneva)
  24041.   Auto-key threshold                 6 (24 ticks)
  24042.   Auto-key rate                      3 (6 ticks)
  24043.   Printer connection                 0 (printer port)
  24044.   Speaker volume                     3 (medium)
  24045.   Double-click time                  8 (32 ticks)
  24046.   Caret-blink time                   8 (32 ticks)
  24047.   Mouse scaling                      1 (on)
  24048.   Preferred system startup disk      0 (internal drive)
  24049.   Menu blink                         3
  24050.  
  24051. Warning:  Your program must not use bits indicated below as “reserved for
  24052.           future use” in parameter RAM, since future Macintosh software
  24053.           features will use them.
  24054.  
  24055. The aTalkA and aTalkB fields are used by the AppleTalk Manager; they’re described in
  24056. the manual Inside AppleTalk.
  24057.  
  24058. The config field indicates which device or devices may use each of the serial ports;
  24059. for details, see the section “Calling the AppleTalk Manager from Assembly Language”
  24060. in the AppleTalk Manager chapter.
  24061.  
  24062. The portA and portB fields contain the baud rates, data bits, stop bits, and parity
  24063. for the device drivers using the modem port (“port A”) and printer port
  24064. (“port B”). An explanation of these terms and the exact format of the information are
  24065. given in the Serial Drivers chapter.
  24066.  
  24067. The alarm field contains the alarm setting in seconds since midnight, January 1,
  24068. 1904.
  24069.  
  24070. The font field contains 1 less than the number of the application font. See the Font
  24071. Manager chapter for a list of font numbers.
  24072.  
  24073. Bit 0 of the kbdPrint field (Figure 1) designates whether the printer (if any) is
  24074. connected to the printer port (0) or the modem port (1). Bits 8-11 of this field
  24075. contain the auto-key rate, the rate of the repeat when a character key is held down;
  24076. this value is stored in two-tick units. Bits 12-15 contain the auto-key threshold,
  24077. the length of time the key must be held down before it begins to repeat; it’s stored
  24078. in four-tick units.
  24079.  
  24080. •••Refer to Figure 1.•••
  24081.  
  24082. Figure 1–The KbdPrint Field
  24083.  
  24084. Bits 0-3 of the volClik field (Figure 2) contain the caret-blink time, and bits 4-7
  24085. contain the double-click time; both values are stored in four-tick units. The caret-blink
  24086. time is the interval between blinks of the caret that marks the insertion point in
  24087. text. The double-click time is the greatest interval between a mouse-up and mouse-down
  24088. event that would qualify two mouse clicks as a double-click. Bits 8-10 of the volClik
  24089. field contain the speaker volume setting, which ranges from silent (0) to loud (7).
  24090.  
  24091. Note:  The Sound Driver procedure SetSoundVol changes the speaker volume
  24092.        without changing the setting in parameter RAM, so it’s possible for
  24093.        the actual volume to be different from this setting.
  24094.  
  24095. Bits 2 and 3 of the misc field (Figure 3) contain a value from 0 to 3 designating how
  24096. many times a menu item will blink when it’s chosen. Bit 4 of this field indicates
  24097. whether the preferred disk to use to start up the system is in the internal (0) or
  24098. the external (1) drive; if there’s any problem using the disk in the specified drive,
  24099. the other drive will be used.
  24100.  
  24101. •••Refer to Figure 2.•••
  24102.  
  24103. Figure 2–The VolClik Field
  24104.  
  24105. •••Refer to Figure 3.•••
  24106.  
  24107. Figure 3–The Misc Field
  24108.  
  24109. Finally, bit 6 of the misc field designates whether mouse scaling is on (1) or off
  24110. (0). If mouse scaling is on, the system looks every sixtieth of a second at whether
  24111. the mouse has moved; if in that time the sum of the mouse’s horizontal and vertical
  24112. changes in position is greater than the mouse-scaling threshold
  24113. (normally six pixels), then the cursor will move twice as far horizontally and vertically
  24114. as it would if mouse scaling were off.
  24115.  
  24116. Assembly-language note:  The mouse-scaling threshold is contained in the
  24117.                          global variable CrsrThresh.
  24118.  
  24119.  
  24120. æKY RestoreA5
  24121. æFp OSUtils.p
  24122. æT PROCEDURE
  24123. æD PROCEDURE RestoreA5;
  24124. æDT RestoreA5;
  24125. æRT 136, 208
  24126. æRI RestoreA5 procedure II-386, N136
  24127. æC Call RestoreA5 at the conclusion of a routine or task that required a call to 
  24128. SetUpA5 (above); it restores register A5 to whatever its value was when SetUpA5 
  24129. was called.
  24130.  
  24131. æKY SetA5
  24132. æFp OSUtils.p
  24133. æT FUNCTION
  24134. æD FUNCTION SetA5(newA5: LONGINT): LONGINT;
  24135. æDT myVariable := SetA5(newA5);
  24136. æRT 208
  24137.  
  24138. æKY SetUpA5
  24139. æFp OSUtils.p
  24140. æT PROCEDURE
  24141. æD PROCEDURE SetUpA5;
  24142. æDT SetUpA5;
  24143. æRT 136,208
  24144. æRI SetUpA5 procedure II-386, N136
  24145. æC SetUpA5 saves the current value of register A5 (for restoring later with RestoreA5, 
  24146. described below) and then resets A5 to point to the boundary between the 
  24147. application globals and the application parameters.  This procedure is useful only 
  24148. within the interrupt environment, where the state of A5 is unpredictable; for 
  24149. instance, in a completion routine or a VBL task, calling SetUpA5 will ensure that A5 
  24150. contains the proper value, allowing the routine or task to access the application 
  24151. globals.
  24152. ________________________________________________________________________
  24153.  
  24154. Assembly-language note:  You can get the boundary between the application 
  24155. globals and the application parameters from the global variable CurrentA5.
  24156. ________________________________________________________________________
  24157.  
  24158. æKY curSysEnvVers
  24159. æFp OSUtils.p
  24160. æC curSysEnvVers = 1; {Updated to equal latest SysEnvirons version}
  24161.  
  24162. æKY Date2Secs
  24163. æFp OSUtils.p
  24164. æT PROCEDURE
  24165. æTN $A9C7
  24166. æD PROCEDURE Date2Secs(d: DateTimeRec;VAR s: LONGINT);
  24167. æDT Date2Secs(d,s);
  24168. æRI Date2Secs procedure  II-379
  24169. æC 
  24170. Trap macro  _Date2Secs
  24171. On entry    A0:  pointer to date/time record
  24172. On exit     D0:  secs (long word)
  24173.  
  24174. Date2Secs takes the given date/time record, converts it to the corresponding number
  24175. of seconds elapsed since midnight, January 1, 1904, and returns the result in the
  24176. secs parameter. The dayOfWeek field of the date/time record is ignored. The values
  24177. passed in the year and month fields should be within their allowable ranges, or
  24178. unpredictable results will occur. The remaining four fields of the date/time record
  24179. may contain any value. For example, September 34 will be interpreted as October 4,
  24180. and you could specify the 300th day of the year as January 300.
  24181.  
  24182. æKY DateTimeRec
  24183. æFp OSUtils.p
  24184. æT RECORD
  24185. æC DateTimeRec = RECORD
  24186.    year: INTEGER;
  24187.    month: INTEGER;
  24188.    day: INTEGER;
  24189.    hour: INTEGER;
  24190.    minute: INTEGER;
  24191.    second: INTEGER;
  24192.    dayOfWeek: INTEGER;
  24193.    END;
  24194.  
  24195. The following utilities are for reading and setting the date and time stored in the
  24196. clock chip. Reading the date and time is a fairly common operation; setting it is
  24197. somewhat rarer, but could be necessary for implementing a desk accessory like the
  24198. Control Panel.
  24199.  
  24200. The date and time setting is stored as an unsigned number of seconds since midnight,
  24201. January 1, 1904; you can use a utility routine to convert this to a date/time record.
  24202. Date/time records are defined as follows:
  24203.  
  24204. TYPE  DateTimeRec = RECORD
  24205.                       year:       INTEGER;  {1904 to 2040}
  24206.                       month:      INTEGER;  {1 to 12 for January to December}
  24207.                       day:        INTEGER;  {1 to 31}
  24208.                       hour:       INTEGER;  {0 to 23}
  24209.                       minute:     INTEGER;  {0 to 59}
  24210.                       second:     INTEGER;  {0 to 59}
  24211.                       dayOfWeek:  INTEGER   {1 to 7 for Sunday to Saturday}
  24212.                     END;
  24213.  
  24214. æKY Delay
  24215. æFp OSUtils.p
  24216. æT PROCEDURE
  24217. æTN $A03B
  24218. æD PROCEDURE Delay(numTicks: LONGINT;VAR finalTicks: LONGINT);
  24219. æDT Delay(numTicks,finalTicks);
  24220. æRT 2
  24221. æRI Delay procedure  II-384
  24222. æC 
  24223. Trap macro  _Delay
  24224. On entry    A0:  numTicks (long word)
  24225. On exit     D0:  finalTicks (long word)
  24226.  
  24227. Delay causes the system to wait for the number of ticks (sixtieths of a second)
  24228. specified by numTicks, and returns in finalTicks the total number of ticks from
  24229. system startup to the end of the delay.
  24230.  
  24231. Warning:  Don’t rely on the duration of the delay being exact; it will usually
  24232.           be accurate to within one tick, but may be off by more than that.
  24233.           The Delay procedure enables all interrupts and checks the tick count
  24234.           that’s incremented during the vertical retrace interrupt; however,
  24235.           it’s possible for this interrupt to be disabled by other interrupts,
  24236.           in which case the duration of the delay will not be exactly what you
  24237.           requested.
  24238.  
  24239. Assembly-language note:  On exit from this procedure, register D0 contains the
  24240.                          value of the global variable Ticks as measured at the
  24241.                          end of the delay.
  24242.  
  24243. æKY Dequeue
  24244. æFp OSUtils.p
  24245. æT FUNCTION
  24246. æTN $A96E
  24247. æD FUNCTION Dequeue(qElement: QElemPtr;qHeader: QHdrPtr): OSErr;
  24248. æDT myVariable := Dequeue(qElement,qHeader);
  24249. æRI Dequeue function  II-383
  24250. æC 
  24251. Trap macro  _Dequeue
  24252. On entry    A0:  qEntry (pointer)
  24253.             A1:  theQueue (pointer)
  24254. On exit     A1:  theQueue (pointer)
  24255.             D0:  result code (word)
  24256.  
  24257. Dequeue removes the queue entry pointed to by qEntry from the queue specified by
  24258. theQueue (without deallocating the entry) and adjusts other entries in the queue
  24259. accordingly.
  24260.  
  24261. Note:  The note under Enqueue above also applies here. In this case, the
  24262.        amount of time interrupts are disabled depends on the length of the
  24263.        queue and the position of the entry in the queue.
  24264.  
  24265. Note:  To remove all entries from a queue, you can just clear all the fields
  24266.        of the queue’s header.
  24267.  
  24268. Result codes    noErr    No error
  24269.                 qErr     Entry not in specified queue
  24270.  
  24271. æKY DTInstall
  24272. æFp OSUtils.p
  24273. æT FUNCTION
  24274. æTN $A075
  24275. æD FUNCTION DTInstall(dtTaskPtr: QElemPtr): OSErr;
  24276. æDT myVariable := DTInstall(dtTaskPtr);
  24277. æRI DTInstall function  V-467
  24278. æC _____________________________________________________________________________________
  24279.  
  24280. Trap macro  _DTInstall
  24281.  
  24282. On entry  A0:  dtTaskPtr (pointer)
  24283.  
  24284. On exit   D0:  result code (word) 
  24285.  
  24286. Note:  
  24287.  
  24288.     To reduce overhead at interrupt time, instead of executing the 
  24289.     _DTInstall trap you can load the jump vector jDTInstall into an address 
  24290.     register other than A0 and execute a JSR instruction using that register. 
  24291. _____________________________________________________________________________________
  24292.  
  24293. DTInstall adds the specified task to the deferred task queue. 
  24294.  
  24295. Your application must fill in all fields of the task except qLink. 
  24296.  
  24297. DTInstall returns one of the result codes listed below.
  24298.  
  24299. Result codes
  24300.  
  24301.   noErr    No error
  24302.   vTypErr  Invalid queue element 
  24303.  
  24304. æKY Enqueue
  24305. æFp OSUtils.p
  24306. æT PROCEDURE
  24307. æTN $A96F
  24308. æD PROCEDURE Enqueue(qElement: QElemPtr;qHeader: QHdrPtr);
  24309. æDT Enqueue(qElement,qHeader);
  24310. æRI Enqueue procedure  II-382
  24311. æC 
  24312. Trap macro  _Enqueue
  24313. On entry    A0:  qEntry (pointer)
  24314.             A1:  theQueue (pointer)
  24315. On exit     A1:  theQueue (pointer)
  24316.  
  24317. Enqueue adds the queue entry pointed to by qEntry to the end of the queue specified
  24318. by theQueue.
  24319.  
  24320. Note:  Interrupts are disabled for a short time while the queue is updated.
  24321.  
  24322. æKY env512KE
  24323. æFp OSUtils.p
  24324. æC env512KE = 1;
  24325.  
  24326. æKY env68000
  24327. æFp OSUtils.p
  24328. æC env68000 = 1;
  24329.  
  24330. æKY env68010
  24331. æFp OSUtils.p
  24332. æC env68010 = 2;
  24333.  
  24334. æKY env68020
  24335. æFp OSUtils.p
  24336. æC env68020 = 3;
  24337.  
  24338. æKY env68030
  24339. æFp OSUtils.p
  24340. æC env68030 = 4;
  24341.  
  24342. æKY envAExtendKbd
  24343. æFp OSUtils.p
  24344. æC envAExtendKbd = 4;
  24345.  
  24346. æKY envCPUUnknown
  24347. æFp OSUtils.p
  24348. æC envCPUUnknown = 0; {CPU types}
  24349.  
  24350. æKY Environs
  24351. æFp OSUtils.p
  24352. æT PROCEDURE
  24353. æD PROCEDURE Environs(VAR rom: INTEGER;VAR machine: INTEGER);
  24354. æDT Environs(rom,machine);
  24355. æRI Environs procedure  II-385, IV-236
  24356. æC 
  24357. [Not in ROM]
  24358.  
  24359. In the rom parameter, Environs returns the current ROM version number (for a Macintosh
  24360. XL, the version number of the ROM image installed by MacWorks). To use the 128K ROM
  24361. information described in this volume, the version number should be greater than or
  24362. equal to 117 ($75). In the machine parameter, Environs returns an indication of which
  24363. machine is in use, as follows:
  24364.  
  24365. CONST  macXLMachine = 0;    {Macintosh XL}
  24366.        macMachine   = 1;    {Macintosh 128K, 512K, 512K upgraded, }
  24367.                             { 512K enhanced, or Macintosh Plus}
  24368.  
  24369. Note:  The machine parameter does not distinguish between the Macintosh 128K,
  24370.        512K, 512K upgraded, 512K enhanced, and Macintosh Plus.
  24371.  
  24372. Assembly-language note:  From assembly language, you can get this information
  24373.                          from the word that’s at an offset of 8 from the
  24374.                          beginning of ROM (which is stored in the global
  24375.                          variable ROMBase). The format of this word is $00xx
  24376.                          for the Macintosh 128K, 512K, 512K enhanced, or
  24377.                          Macintosh Plus, and $xxFF for the Macintosh XL, where
  24378.                          xx is the ROM version number. (The ROM version number
  24379.                          will always be between $01 and $FE.)
  24380.  
  24381. æKY envMac
  24382. æFp OSUtils.p
  24383. æC envMac = -1; {Environs Equates}
  24384.  
  24385. æKY envMacAndPad
  24386. æFp OSUtils.p
  24387. æC envMacAndPad = 2;
  24388.  
  24389. æKY envMachUnknown
  24390. æFp OSUtils.p
  24391. æC envMachUnknown = 0;
  24392.  
  24393. æKY envMacKbd
  24394. æFp OSUtils.p
  24395. æC envMacKbd = 1;
  24396.  
  24397. æKY envMacPlus
  24398. æFp OSUtils.p
  24399. æC envMacPlus = 2;
  24400.  
  24401. æKY envMacPlusKbd
  24402. æFp OSUtils.p
  24403. æC envMacPlusKbd = 3;
  24404.  
  24405. æKY envSE
  24406. æFp OSUtils.p
  24407. æC envSE = 3;
  24408.  
  24409. æKY envSE30
  24410. æFp OSUtils.p
  24411. æC envSE30 = 7;
  24412.  
  24413. æKY envStandADBKbd
  24414. æFp OSUtils.p
  24415. æC envStandADBKbd = 5;
  24416.  
  24417. æKY envUnknownKbd
  24418. æFp OSUtils.p
  24419. æC envUnknownKbd = 0; {Keyboard types}
  24420.  
  24421. æKY envXL
  24422. æFp OSUtils.p
  24423. æC envXL = -2;
  24424.  
  24425. æKY EqualString
  24426. æFp OSUtils.p
  24427. æT FUNCTION
  24428. æTN $A03C
  24429. æD FUNCTION EqualString(str1: Str255;str2: Str255;caseSens: BOOLEAN;diacSens: BOOLEAN): BOOLEAN;
  24430. æDT myVariable := EqualString(str1,str2,caseSens,diacSens);
  24431. æRI EqualString function  II-377
  24432. æC 
  24433. Assembly-language note:  The trap macros for these utility routines have
  24434.                          optional arguments corresponding to the Pascal flags
  24435.                          passed to the routines. When present, such an argument
  24436.                          sets a certain bit of the routine trap word; this is
  24437.                          equivalent to setting the corresponding Pascal flag to
  24438.                          either TRUE or FALSE, depending on the flag. The trap
  24439.                          macros for these routines are listed with all the
  24440.                          possible permutations of arguments. Whichever
  24441.                          permutation you use, you must type it exactly as shown.
  24442.                          (The syntax shown applies to the Lisa Workshop
  24443.                          Assembler; programmers using another development
  24444.                          system should consult its documentation for the proper
  24445.                          syntax.)
  24446.  
  24447.  
  24448. Trap macro  _CmpString
  24449.             _CmpString ,MARKS       (sets bit 9, for diacSens=FALSE)
  24450.             _CmpString ,CASE        (sets bit 10, for caseSens=TRUE)
  24451.             _CmpString ,MARKS,CASE  (sets bits 9 and 10)
  24452. On entry    A0:    pointer to first character of first string
  24453.             A1:    pointer to first character of second string
  24454.             D0:    high-order word:  length of first string
  24455.                    low-order word:  length of second string
  24456. On exit     D0:    0 if strings equal, 1 if strings not equal (long word)
  24457.  
  24458. EqualString compares the two given strings for equality on the basis of their ASCII
  24459. values. If caseSens is TRUE, uppercase characters are distinguished from the corresponding
  24460. lowercase characters. If diacSens is FALSE, diacritical marks are ignored during the
  24461. comparison. The function returns TRUE if the strings are equal.
  24462.  
  24463. Note:  See also the International Utilities Package function IUEqualString.
  24464.  
  24465. æKY false32b,true32b
  24466. æFp OSUtils.p
  24467. æC 
  24468.   { Addressing modes }
  24469.  
  24470.   false32b      = 0;     {24-bit addressing mode}
  24471.   true32b       = 1;     {32-bit addressing mode}
  24472.  
  24473. æKY FlushDataCache
  24474. æFp OSUtils.p
  24475. æT PROCEDURE
  24476. æD PROCEDURE FlushDataCache;
  24477. æDT FlushDataCache;
  24478.  
  24479. æKY FlushInstructionCache
  24480. æFp OSUtils.p
  24481. æT PROCEDURE
  24482. æD PROCEDURE FlushInstructionCache;
  24483. æDT FlushInstructionCache;
  24484.  
  24485. æKY GetDateTime
  24486. æFp OSUtils.p
  24487. æT PROCEDURE
  24488. æD PROCEDURE GetDateTime(VAR secs: LONGINT);
  24489. æDT GetDateTime(secs);
  24490. æRI GetDateTime procedure  II-378
  24491. æC 
  24492. GetDateTime returns in the secs parameter the contents of the low-memory location in
  24493. which the date and time setting is stored; if this setting reflects the actual current
  24494. date and time, secs will contain the number of seconds between midnight, January 1,
  24495. 1904 and the time that the function was called.
  24496.  
  24497. Note:  If your application disables interrupts for longer than a second,
  24498.        the number of seconds returned will not be exact.
  24499.  
  24500. Assembly-language note:  Assembly-language programmers can just access
  24501.                          the global variable Time.
  24502.  
  24503. If you wish, you can convert the value returned by GetDateTime to a date/time record
  24504. by calling the Secs2Date procedure.
  24505.  
  24506. Note:  Passing the value returned by GetDateTime to the International
  24507.        Utilities Package procedure IUDateString or IUTimeString will yield
  24508.        a string representing the corresponding date or time of day,
  24509.        respectively.
  24510.  
  24511. æKY GetMMUMode
  24512. æFp OSUtils.p
  24513. æT FUNCTION
  24514. æD FUNCTION GetMMUMode: SignedByte;
  24515. æDT myVariable := GetMMUMode;
  24516. æRT 228
  24517. æRI GetMMUMode function  V-592
  24518. æC 
  24519. [Not in ROM]
  24520.  
  24521. GetMMUMode returns the address translation mode currently in use.
  24522.  
  24523. Assembly-language note:  Assembly-language programmers can determine the
  24524.                          current address mode by testing the contents of
  24525.                          the global variable MMU32Bit; it’s TRUE if 32-bit
  24526.                          mode is in effect.
  24527.  
  24528. •••Refer to Technical Note #228:•••
  24529.  
  24530. æKY GetSysPPtr
  24531. æFp OSUtils.p
  24532. æT FUNCTION
  24533. æD FUNCTION GetSysPPtr: SysPPtr;
  24534. æDT myVariable := GetSysPPtr;
  24535. æRI GetSysPPtr function  II-381
  24536. æC  
  24537. [Not in ROM]
  24538.  
  24539. GetSysPPtr returns a pointer to the low-memory copy of parameter RAM. You can examine
  24540. the values stored in its various fields, or change them before calling WriteParam
  24541. (below).
  24542.  
  24543. Assembly-language note:  Assembly-language programmers can simply access the
  24544.                          global variables corresponding to the low-memory copy
  24545.                          of parameter RAM. These variables, which begin at the
  24546.                          address SysParam, are listed in the summary.
  24547.  
  24548. æKY GetTime
  24549. æFp OSUtils.p
  24550. æT PROCEDURE
  24551. æD PROCEDURE GetTime(VAR d: DateTimeRec);
  24552. æDT GetTime(d);
  24553. æRI GetTime procedure  II-380
  24554. æC  
  24555. GetTime takes the number of seconds elapsed since midnight, January 1, 1904
  24556. (obtained by calling GetDateTime), converts that value into a date and time (by
  24557. calling Secs2Date), and returns the result in the date parameter.
  24558.  
  24559. Assembly-language note:  From assembly language, you can pass the value
  24560.                          of the global variable Time to Secs2Date.
  24561.  
  24562. æKY GetTrapAddress
  24563. æFp OSUtils.p
  24564. æT FUNCTION
  24565. æTN $A146
  24566. æD FUNCTION GetTrapAddress(trapNum: INTEGER): LONGINT;
  24567. æDT myVariable := GetTrapAddress(trapNum);
  24568. æRT 2
  24569. æRI GetTrapAddress function  II-384, IV-234, N2-4
  24570. æC 
  24571. Trap macro  _GetTrapAddress
  24572. On entry    D0:  trapNum (word)
  24573. On exit     A0:  address of routine
  24574.  
  24575. GetTrapAddress returns the address of a routine currently installed in the trap
  24576. dispatch table under the trap number designated by trapNum. To find out the trap
  24577. number for a particular routine, see Appendix C.
  24578.  
  24579. Assembly-language note:  When you use this technique to bypass the trap
  24580.                          dispatcher, you don’t get the extra level of register
  24581.                          saving. The routine itself will preserve A2-A6 and
  24582.                          D3-D7, but if you want any other registers preserved
  24583.                          across the call you have to save and restore them
  24584.                          yourself.
  24585.  
  24586. æKY HandAndHand
  24587. æFp OSUtils.p
  24588. æT FUNCTION
  24589. æTN $A9E4
  24590. æD FUNCTION HandAndHand(aHndl: Handle;bHndl: Handle): OSErr;
  24591. æDT myVariable := HandAndHand(aHndl,bHndl);
  24592. æMM   
  24593. æRI HandAndHand function II-375
  24594. æC 
  24595. Trap macro  _HandAndHand
  24596. On entry    A0:  aHndl (handle)
  24597.             A1:  bHndl (handle)
  24598. On exit     A0:  bHndl (handle)
  24599.             D0:  result code (word)
  24600.  
  24601. HandAndHand concatenates the information to which aHndl is a handle onto the end of
  24602. the information to which bHndl is a handle.
  24603.  
  24604. Warning:  HandAndHand dereferences aHndl, so be sure to call the Memory
  24605.           Manager procedure HLock to lock the block before calling HandAndHand.
  24606.  
  24607. Result codes    noErr           No error
  24608.                 memFullErr      Not enough room in heap zone
  24609.                 nilHandleErr    NIL master pointer
  24610.                 memWZErr        Attempt to operate on a free block
  24611.  
  24612. æKY HandToHand
  24613. æFp OSUtils.p
  24614. æT FUNCTION
  24615. æTN $A9E1
  24616. æD FUNCTION HandToHand(VAR theHndl: Handle): OSErr;
  24617. æDT myVariable := HandToHand(theHndl);
  24618. æMM   
  24619. æRI HandToHand function II-374
  24620. æC 
  24621. Trap macro  _HandToHand
  24622. On entry    A0:  theHndl (handle)
  24623. On exit     A0:  theHndl (handle)
  24624.             D0:  result code (word)
  24625.  
  24626. HandToHand copies the information to which theHndl is a handle and returns a new
  24627. handle to the copy in theHndl. Since HandToHand replaces the input parameter with a
  24628. new handle, you should retain the original value of the input parameter somewhere
  24629. else, or you won’t be able to access it. For example:
  24630.  
  24631.   VAR    x,y:  Handle;
  24632.          err:  OSErr;
  24633.   y := x;
  24634.   err := HandToHand(y)
  24635.  
  24636. The original handle remains in x while y becomes a different handle to an identical
  24637. copy of the data.
  24638.  
  24639. Result codes    noErr           No error
  24640.                 memFullErr      Not enough room in heap zone
  24641.                 nilHandleErr    NIL master pointer
  24642.                 memWZErr        Attempt to operate on a free block
  24643.  
  24644. æKY InitUtil
  24645. æFp OSUtils.p
  24646. æT FUNCTION
  24647. æTN $A03F
  24648. æD FUNCTION InitUtil: OSErr;
  24649. æDT myVariable := InitUtil;
  24650. æRI InitUtil function II-380
  24651. æC 
  24652. Trap macro  _InitUtil
  24653. On exit     D0:  result code (word)
  24654.  
  24655. •••Refer to Figure 4.•••
  24656.  
  24657. Figure 4–Parameter RAM Routines
  24658.  
  24659. InitUtil copies the contents of parameter RAM into 20 bytes of low memory and copies
  24660. the date and time from the clock chip into its own low-memory location. This routine
  24661. is called at system startup; you’ll probably never need to call it yourself.
  24662.  
  24663. Assembly-language note:  InitUtil copies parameter RAM into 20 bytes starting
  24664.                          at the address SysParam and copies the date and time
  24665.                          into the global variable Time.
  24666.  
  24667. If the validity status in parameter RAM is not $A8 when InitUtil is called, an error
  24668. is returned as the result code, and the default values (given in the
  24669. “Parameter RAM” section) are read into the low-memory copy of parameter RAM; these
  24670. values are then written to the clock chip itself.
  24671.  
  24672. Result codes    noErr        No error
  24673.                 prInitErr    Validity status not $A8
  24674.  
  24675. æKY KeyTrans
  24676. æFp OSUtils.p
  24677. æT FUNCTION
  24678. æTN $A9C3
  24679. æD FUNCTION KeyTrans(transData: Ptr;keycode: INTEGER;VAR state: LONGINT): LONGINT;
  24680. æDT myVariable := KeyTrans(transData,keycode,state);
  24681. æRT 160
  24682. æRI KeyTrans function  V-195, N160
  24683. æC 
  24684. [256K ROM]
  24685.  
  24686. KeyTrans lets your application convert key codes to ASCII values as determined by a
  24687. 'KCHR' resource.  The 'KCHR' resource type is discussed in the Resource Manager
  24688. chapter.
  24689.  
  24690. TransData points to a 'KCHR' resource, which maps virtual key codes to ASCII values. 
  24691. The keycode parameter is a 16-bit value with the structure shown in Figure 9.
  24692.  
  24693. •••Refer to Figure 9.•••
  24694.  
  24695. Figure 9–Keycode Parameter Structure
  24696.  
  24697. The state parameter is a value maintained by the Toolbox.  Your application should
  24698. save it between calls to KeyTrans.  If your application changes transData to point to
  24699. a different 'KCHR' resource, it should reset the state value to 0.
  24700.  
  24701. KeyTrans returns a 32-bit value with the structure shown in Figure 10.  In this
  24702. structure, ASCII 1 is the ASCII value of the first character generated by the key
  24703. code parameter; reserved1 is an extension for future “16-bit ASCII” coding.  ASCII 2
  24704. and reserved2 have the same meanings for a possible second character generated by key
  24705. code—for example, if key code designates an alphabetic character with a separate
  24706. accent character.
  24707.  
  24708. •••Refer to Figure 10.•••
  24709.  
  24710. Figure 10–KeyTrans Return Structure
  24711.  
  24712. Assembly-language note:  The macro you invoke to call KeyTrans from assembly
  24713.                          language is named _KeyTrans. Its parameters are
  24714.                          passed on the stack.
  24715.  
  24716. æKY macXLMachine,macMachine
  24717. æFp OSUtils.p
  24718. æC 
  24719.   { Values returned by Environs procedure }
  24720.  
  24721.   macXLMachine  = 0;     {Macintosh XL}
  24722.   macMachine    = 1;     {Macintosh 128K, 512K, 512K upgraded, }
  24723.                          { 512K enhanced, or Macintosh Plus}
  24724.  
  24725. æKY NGetTrapAddress
  24726. æFp OSUtils.p
  24727. æT FUNCTION
  24728. æD FUNCTION NGetTrapAddress(trapNum: INTEGER;tTyp: TrapType): LONGINT;
  24729. æDT myVariable := NGetTrapAddress(trapNum,tTyp);
  24730. æRT 156, 212
  24731. æRI NGetTrapAddress function  IV-234, N156-3
  24732. æC  
  24733. [Not in ROM]
  24734.  
  24735. NGetTrapAddress is identical to GetTrapAddress except that it requires you to specify
  24736. in tType whether the given routine is an Operating System or a Toolbox trap.
  24737.  
  24738. Trap macro  _GetTrapAddress ,NEWOS    (bit 9 set, bit 10 clear)
  24739.             _GetTrapAddress ,NEWTOOL  (bit 9 set, bit 10 set) 
  24740. On entry    D0:  trapNum (word)
  24741. On exit     A0:  address of routine
  24742.  
  24743. æKY NSetTrapAddress
  24744. æFp OSUtils.p
  24745. æT PROCEDURE
  24746. æD PROCEDURE NSetTrapAddress(trapAddr: LONGINT;trapNum: INTEGER;tTyp: TrapType);
  24747. æDT NSetTrapAddress(trapAddr,trapNum,tTyp);
  24748. æRI NSetTrapAddress procedure  IV-234
  24749. æC  
  24750. [Not in ROM]
  24751.  
  24752. NSetTrapAddress is identical to SetTrapAddress except that it requires you to specify
  24753. in tType whether the given routine is an Operating System or a Toolbox trap.
  24754.  
  24755. Trap macro  _SetTrapAddress ,NEWOS    (bit 9 set, bit 10 clear)
  24756.             _SetTrapAddress ,NEWTOOL  (bit 9 set, bit 10 set)
  24757. On entry    A0:  trapAddr (address)
  24758.             D0:  trapNum (word)
  24759.             
  24760. æKY PtrAndHand
  24761. æFp OSUtils.p
  24762. æT FUNCTION
  24763. æTN $A9EF
  24764. æD FUNCTION PtrAndHand(ptr1: Ptr;hndl: Handle;size: LONGINT): OSErr;
  24765. æDT myVariable := PtrAndHand(ptr1,hndl,size);
  24766. æMM   
  24767. æRI PtrAndHand function II-376
  24768. æC 
  24769. Trap macro  _PtrAndHand
  24770. On entry    A0:  pntr (pointer)
  24771.             A1:  hndl (handle)
  24772.             D0:  size (long word)
  24773. On exit     A0:  hndl (handle)
  24774.             D0:  result code (word)
  24775.  
  24776. PtrAndHand takes the number of bytes specified by the size parameter, beginning at
  24777. the location specified by pntr, and concatenates them onto the end of the information
  24778. to which hndl is a handle.
  24779.  
  24780. Result codes    noErr           No error
  24781.                 memFullErr      Not enough room in heap zone
  24782.                 nilHandleErr    NIL master pointer
  24783.                 memWZErr        Attempt to operate on a free block
  24784.  
  24785. æKY PtrToHand
  24786. æFp OSUtils.p
  24787. æT FUNCTION
  24788. æTN $A9E3
  24789. æD FUNCTION PtrToHand(srcPtr: Ptr;VAR dstHndl: Handle;size: LONGINT): OSErr;
  24790. æDT myVariable := PtrToHand(srcPtr,dstHndl,size);
  24791. æMM   
  24792. æRI PtrToHand function II-375
  24793. æC 
  24794. Trap macro  _PtrToHand
  24795. On entry    A0:  srcPtr (pointer)
  24796.             D0:  size (long word)
  24797. On exit     A0:  dstHndl (handle)
  24798.             D0:  result code (word)
  24799.  
  24800. PtrToHand returns in dstHndl a newly created handle to a copy of the number of bytes
  24801. specified by the size parameter, beginning at the location specified by srcPtr.
  24802.  
  24803. Result codes    noErr         No error
  24804.                 memFullErr    Not enough room in heap zone
  24805.  
  24806. æKY PtrToXHand
  24807. æFp OSUtils.p
  24808. æT FUNCTION
  24809. æTN $A9E2
  24810. æD FUNCTION PtrToXHand(srcPtr: Ptr;dstHndl: Handle;size: LONGINT): OSErr;
  24811. æDT myVariable := PtrToXHand(srcPtr,dstHndl,size);
  24812. æMM   
  24813. æRI PtrToXHand function II-375
  24814. æC 
  24815. Trap macro  _PtrToXHand
  24816. On entry    A0:  srcPtr (pointer)
  24817.             A1:  dstHndl (handle)
  24818.             D0:  size (long word)
  24819. On exit     A0:  dstHndl (handle)
  24820.             D0:  result code (word)
  24821.  
  24822. PtrToXHand takes the existing handle specified by dstHndl and makes it a handle to a
  24823. copy of the number of bytes specified by the size parameter, beginning at the location
  24824. specified by srcPtr.
  24825.  
  24826. Result codes    noErr           No error
  24827.                 memFullErr      Not enough room in heap zone
  24828.                 nilHandleErr    NIL master pointer
  24829.                 memWZErr        Attempt to operate on a free block
  24830.  
  24831. æKY QTypes,dummyType,vType,ioQType,drvQType,evType,fsQType
  24832. æFp OSUtils.p
  24833. æC QTypes = (dummyType,vType,ioQType,drvQType,evType,fsQType );
  24834.  
  24835. æKY ReadDateTime
  24836. æFp OSUtils.p
  24837. æT FUNCTION
  24838. æTN $A039
  24839. æD FUNCTION ReadDateTime(VAR time: LONGINT): OSErr;
  24840. æDT myVariable := ReadDateTime(time);
  24841. æRI ReadDateTime function II-378
  24842. æC 
  24843. Trap macro  _ReadDateTime
  24844. On entry    A0:  pointer to long word secs
  24845. On exit     A0:  pointer to long word secs
  24846.             D0:  result code (word)
  24847.  
  24848. ReadDateTime copies the date and time stored in the clock chip to a low-memory location
  24849. and returns it in the secs parameter. This routine is called at system startup;
  24850. you’ll probably never need to call it yourself. Instead you’ll call GetDateTime (see
  24851. below).
  24852.  
  24853. Assembly-language note:  The low-memory location to which ReadDateTime
  24854.                          copies the date and time is the global variable Time.
  24855.  
  24856. Result codes    noErr       No error
  24857.                 clkRdErr    Unable to read clock
  24858.  
  24859. æKY RelString
  24860. æFp OSUtils.p
  24861. æT FUNCTION
  24862. æTN $A050
  24863. æD FUNCTION RelString(str1: Str255;str2: Str255;caseSens: BOOLEAN;diacSens: BOOLEAN): INTEGER;
  24864. æDT myVariable := RelString(str1,str2,caseSens,diacSens);
  24865. æRI RelString function  IV-234
  24866. æC 
  24867. Assembly-language note:  The trap macros for these utility routines have
  24868.                          optional arguments corresponding to the Pascal flags
  24869.                          passed to the routines. When present, such an argument
  24870.                          sets a certain bit of the routine trap word; this is
  24871.                          equivalent to setting the corresponding Pascal flag to
  24872.                          either TRUE or FALSE, depending on the flag. The trap
  24873.                          macros for these routines are listed with all the
  24874.                          possible permutations of arguments. Whichever
  24875.                          permutation you use, you must type it exactly as shown.
  24876.                          (The syntax shown applies to the Lisa Workshop
  24877.                          Assembler; programmers using another development
  24878.                          system should consult its documentation for the proper
  24879.                          syntax.)
  24880.  
  24881. RelString is similar to EqualString except that it indicates whether the first string
  24882. is less than, equal to, or greater than the second string by returning either –1, 0,
  24883. or 1 respectively.
  24884.  
  24885. Trap macro  _RelString
  24886.             _RelString ,MARKS       (sets bit 9, for diacSens=FALSE)
  24887.             _RelString ,CASE        (sets bit 10, for caseSens=TRUE)
  24888.             _RelString ,MARKS,CASE  (sets bits 9 and 10)
  24889. On entry    A0:  pointer to first character of first string
  24890.             A1:  pointer to first character of second string
  24891.             D0:  high-order word:  length of first string
  24892.                  low-order word:  length of second string
  24893. On exit     D0:  –1 if first string less than second, 0 if equal,
  24894.                   1 if first string greater than second (long word)
  24895.  
  24896. RelString follows the sort order described in the International Utilities Package
  24897. chapter except for the reordering of the following ligatures:
  24898.  
  24899.   Æ falls between Å and a
  24900.   æ falls between å and B
  24901.   Œ falls between Ø and o
  24902.   œ falls between ø and P
  24903.   ß falls between s and T
  24904.  
  24905. If diacSens is FALSE, diacritical marks are ignored; RelString strips diacriticals
  24906. according to the following table:
  24907.  
  24908.   A    <--    Ä, Å, À, Ã
  24909.   C    <--    Ç
  24910.   E    <--    É
  24911.   N    <--    Ñ
  24912.   O    <--    Ö, Õ, Ø
  24913.   U    <--    Ü
  24914.   a    <--    á, à, â, ä, ã, å, ª
  24915.   c    <--    ç
  24916.   e    <--    é, è, ê, ë
  24917.   i    <--    í, ì, î, ï
  24918.   n    <--    ñ
  24919.   o    <--    ó, ò, ô, ö, õ, ø, º
  24920.   u    <--    ú, ù, û, ü
  24921.   y    <--    ÿ
  24922.  
  24923. Note:  This stripping is identical to that performed by the UprString
  24924.        procedure when the diacSens parameter is FALSE.
  24925.  
  24926. If caseSens is FALSE, the comparison is not case-sensitive; RelString performs a
  24927. conversion from lower-case to upper-case characters according to the following table:
  24928.  
  24929.   A    <--    a
  24930.   ...  <--    ...
  24931.   Z    <--    z
  24932.   À    <--    à
  24933.   Ã    <--    ã
  24934.   Ä    <--    ä
  24935.   Å    <--    å
  24936.   Æ    <--    æ
  24937.   Ç    <--    ç
  24938.   É    <--    é
  24939.   Ñ    <--    ñ
  24940.   Ö    <--    ö
  24941.   Õ    <--    õ
  24942.   Ø    <--    ø
  24943.   Œ    <--    œ
  24944.   Ü    <--    ü
  24945.  
  24946. Note:  This conversion is identical to that performed by the UprString
  24947.        procedure.
  24948.  
  24949. æKY Restart
  24950. æFp OSUtils.p
  24951. æT PROCEDURE
  24952. æD PROCEDURE Restart;
  24953. æDT Restart;
  24954. æMM   
  24955. æRT 208
  24956. æRI Restart procedure II-385
  24957. æC 
  24958. [Not in ROM]
  24959.  
  24960. This procedure restarts the system.
  24961.  
  24962. Assembly-language note:  From assembly language, you can give the following
  24963.                          instructions to restart the system:
  24964.  
  24965.                            MOVE.L    ROMBase,A0
  24966.                            JMP       $0A(A0)
  24967.  
  24968. Note:  The procedures SetUpA5 and RestoreA5 were formerly documented in this
  24969.        chapter; however, two routines with more functionality are now available
  24970.        with the MPW 3.0 and later libraries.  The routines SetCurrentA5 and
  24971.        SetA5 are documented in Macintosh Technical Note #208.
  24972.  
  24973. •••Refer to Technical Note #208:•••
  24974.  
  24975. æKY Secs2Date
  24976. æFp OSUtils.p
  24977. æT PROCEDURE
  24978. æTN $A9C6
  24979. æD PROCEDURE Secs2Date(s: LONGINT;VAR d: DateTimeRec);
  24980. æDT Secs2Date(s,d);
  24981. æRI Secs2Date procedure II-380
  24982. æC 
  24983. Trap macro  _Secs2Date
  24984. On entry    D0:  secs (long word)
  24985. On exit     A0:  pointer to date/time record
  24986.  
  24987. Secs2Date takes a number of seconds elapsed since midnight, January 1, 1904 as specified
  24988. by the secs parameter, converts it to the corresponding date and time, and returns
  24989. the corresponding date/time record in the date parameter.
  24990.  
  24991. æKY SetCurrentA5
  24992. æFp OSUtils.p
  24993. æT FUNCTION
  24994. æD FUNCTION SetCurrentA5: LONGINT;
  24995. æDT myVariable := SetCurrentA5;
  24996. æRT 208
  24997.  
  24998.  
  24999. æKY SetDateTime
  25000. æFp OSUtils.p
  25001. æT FUNCTION
  25002. æTN $A03A
  25003. æD FUNCTION SetDateTime(time: LONGINT): OSErr;
  25004. æDT myVariable := SetDateTime(time);
  25005. æRI SetDateTime function II-379
  25006. æC 
  25007. Trap macro  _SetDateTime
  25008. On entry    D0:  secs (long word)
  25009. On exit     D0:  result code (word)
  25010.  
  25011. SetDateTime takes a number of seconds since midnight, January 1, 1904, as specified
  25012. by the secs parameter, and writes it to the clock chip as the current date and time.
  25013. It then attempts to read the value just written and verify it by comparing it to the
  25014. secs parameter.
  25015.  
  25016. Assembly-language note:  SetDateTime updates the global variable Time to
  25017.                          the value of the secs parameter.
  25018.  
  25019. Result codes    noErr       No error
  25020.                 clkWrErr    Time written did not verify
  25021.                 clkRdErr    Unable to read clock
  25022.  
  25023. æKY SetTime
  25024. æFp OSUtils.p
  25025. æT PROCEDURE
  25026. æD PROCEDURE SetTime(d: DateTimeRec);
  25027. æDT SetTime(d);
  25028. æRI SetTime procedure II-380
  25029. æC  
  25030. SetTime takes the date and time specified by the date parameter, converts it into the
  25031. corresponding number of seconds elapsed since midnight, January 1, 1904 (by calling
  25032. Date2Secs), and then writes that value to the clock chip as the current date and time
  25033. (by calling SetDateTime).
  25034.  
  25035. Assembly-language note:  From assembly language, you can just call Date2Secs
  25036.                          and SetDateTime directly.
  25037.  
  25038. æKY SetTrapAddress
  25039. æFp OSUtils.p
  25040. æT PROCEDURE
  25041. æTN $A047
  25042. æD PROCEDURE SetTrapAddress(trapAddr: LONGINT;trapNum: INTEGER);
  25043. æDT SetTrapAddress(trapAddr,trapNum);
  25044. æRT 2
  25045. æRI SetTrapAddress procedure II-384, IV-234, N2-4
  25046. æC 
  25047. Trap macro  _SetTrapAddress
  25048. On entry    A0:  trapAddr (address)
  25049.             D0:  trapNum (word)
  25050.  
  25051. SetTrapAddress installs in the trap dispatch table a routine whose address is trapAddr;
  25052. this routine is installed under the trap number designated by trapNum.
  25053.  
  25054. Warning:  Since the trap dispatch table can address locations within a range
  25055.           of only 64K bytes from the beginning of the system heap, the routine
  25056.           you install should be in the system heap.
  25057.  
  25058. Assembly-language note:  To use GetTrapAddress and SetTrapAddress with
  25059.                          128K ROM routines, set bit 9 of the trap word to
  25060.                          indicate the new trap numbering. The state of bit
  25061.                          10 then determines whether the intended trap is a
  25062.                          Toolbox or Operating System trap. You can set these
  25063.                          two bits with the arguments NEWOS and NEWTOOL.
  25064.  
  25065.                          Of course, the 64K ROM versions of GetTrapAddress and
  25066.                          SetTrapAddress will fail if applied to traps that
  25067.                          exist only in the 128K ROM.
  25068.  
  25069.                          The NGetTrapAddress and NSetTrapAddress routines list
  25070.                          the possible permutations of arguments. (The syntax
  25071.                          shown applies to the Lisa Workshop Assembler;
  25072.                          programmers using another development system should
  25073.                          consult its documentation for the proper syntax.)
  25074.  
  25075. æKY sortsAfter
  25076. æFp OSUtils.p
  25077. æC sortsAfter = 1; {first string > second string}
  25078.  
  25079. æKY sortsBefore
  25080. æFp OSUtils.p
  25081. æC sortsBefore = -1; {first string < second string}
  25082.  
  25083. æKY sortsEqual
  25084. æFp OSUtils.p
  25085. æC sortsEqual = 0; {first string = second string}
  25086.  
  25087. æKY SwapDataCache
  25088. æFp OSUtils.p
  25089. æT FUNCTION
  25090. æD FUNCTION SwapDataCache(cacheEnable: BOOLEAN): BOOLEAN;
  25091. æDT myVariable := SwapDataCache(cacheEnable);
  25092.  
  25093. æKY SwapInstructionCache
  25094. æFp OSUtils.p
  25095. æT FUNCTION
  25096. æD FUNCTION SwapInstructionCache(cacheEnable: BOOLEAN): BOOLEAN;
  25097. æDT myVariable := SwapInstructionCache(cacheEnable);
  25098.  
  25099. æKY SwapMMUMode
  25100. æFp OSUtils.p
  25101. æT PROCEDURE
  25102. æTN $A05D
  25103. æD PROCEDURE SwapMMUMode(VAR mode: SignedByte);
  25104. æDT SwapMMUMode(mode);
  25105. æRI SwapMMUMode procedure  V-593, C1-6
  25106. æC 
  25107. Trap macro  _SwapMMUMode
  25108. On entry    D0:  mode (byte)
  25109. On exit     D0:  mode (byte)
  25110.  
  25111. SwapMMUMode sets the address translation mode to that specified by the mode parameter.
  25112.  The mode in use prior to the call is returned in mode, and can be restored with
  25113. another call to SwapMMUMode.
  25114.  
  25115. æKY SysBeep
  25116. æFp OSUtils.p
  25117. æT PROCEDURE
  25118. æTN $A9C8
  25119. æD PROCEDURE SysBeep(duration: INTEGER);
  25120. æDT SysBeep(duration);
  25121. æMM   
  25122. æRI SysBeep procedure II-385, V-592
  25123. æC  
  25124. SysBeep causes the system to beep for approximately the number of ticks specified by
  25125. the duration parameter. The sound decays from loud to soft; after about five seconds
  25126. it’s inaudible. The initial volume of the beep depends on the current speaker volume
  25127. setting, which the user can adjust with the Control Panel desk accessory. If the
  25128. speaker volume has been set to 0 (silent), SysBeep instead causes the menu bar to
  25129. blink once.
  25130.  
  25131. Assembly-language note:  Unlike all other Operating System Utilities, this
  25132.                          procedure is stack-based.
  25133.  
  25134. æKY SysEnvirons
  25135. æFp OSUtils.p
  25136. æT FUNCTION
  25137. æTN $A090
  25138. æD FUNCTION SysEnvirons(versionRequested: INTEGER;VAR theWorld: SysEnvRec): OSErr;
  25139. æDT myVariable := SysEnvirons(versionRequested,theWorld);
  25140. æRT 67, 103, 156, 184, 190,  207,212
  25141. æRI SysEnvirons function  V-5, N129, N156
  25142. æC 
  25143. ———————————————————————————————————————————————————————————————————————————————
  25144. »DETERMINING THE FEATURES OF A MACHINE                  CompatibilityGuide
  25145. _______________________________________________________________________________
  25146.  
  25147. As the Macintosh family grows, applications need a reliable and comprehensive way of
  25148. determining what software and hardware features are available on a given machine. 
  25149. Although the Operating System Utilities routine Environs indicates the type of machine
  25150. and ROM version running, it provides no help in distinguishing between the plethora
  25151. of different software feature sets and hardware configurations that an application
  25152. may encounter.
  25153.  
  25154. A new function, SysEnvirons, provides detailed information about what software functionality
  25155. (Color QuickDraw, as an example) is available, as well as what hardware devices
  25156. (processors, peripherals, and so on) are installed or connected.
  25157.  
  25158. All of the Toolbox Managers must be initialized before calling SysEnvirons.
  25159. In addition, the AppleTalk Manager routine MPPOpen must be called if the driver
  25160. version information in atDrvrVersNum is desired.  SysEnvirons is not intended for use
  25161. by device drivers, but can be called from desk accessories. (It does not assume that
  25162. register A5 has been properly set up.)
  25163.  
  25164. FUNCTION SysEnvirons (versionReqested: INTEGER;
  25165.                       VAR theWorld: SysEnvRec) : OSErr;  [Not in ROM]
  25166.  
  25167. •••Refer to Technical Note #129:•••
  25168.  
  25169. Trap macro    _SysEnvirons
  25170. On entry    A0:  sysEnvRec (pointer)
  25171.             D0:  versReqested (word)
  25172. On exit     A0:  sysEnvRec (pointer)
  25173.             D0:  result code (word)
  25174.  
  25175. Result codes    noErr            No error
  25176.                 envNotPresent    SysEnvirons trap not present
  25177.                 envBadVers       Nonpositive version number passed
  25178.                 envVersTooBig    Requested version of SysEnvirons
  25179.                                  call not available
  25180.  
  25181. In theWorld, SysEnvirons returns a system environment record describing the features
  25182. of the machine.  Designed to be extendible, SysEnvirons will be updated as new features
  25183. are added, and the system environment record that’s returned will be expanded. 
  25184. System File 4.1 contains version 1 of SysEnvirons; subsequent versions will be incremented
  25185. by 1.
  25186.  
  25187. The system environment record for version 1 of SysEnvirons contains the following
  25188. fields:
  25189.  
  25190. TYPE  SysEnvRec = RECORD
  25191.                     environsVersion:  INTEGER;
  25192.                     machineType:      INTEGER;
  25193.                     systemVersion:    INTEGER;
  25194.                     processor:        INTEGER;
  25195.                     hasFPU:           BOOLEAN;
  25196.                     hasColorQD:       BOOLEAN;
  25197.                     keyBoardType:     INTEGER;
  25198.                     atDrvrVersNum:    INTEGER;
  25199.                     sysVRefNum:       INTEGER
  25200.                   END;
  25201.  
  25202. New versions of the call will add fields to this record.  To distinguish between
  25203. different versions of the call, and thereby between the different sizes of records
  25204. they return, SysEnvirons returns its version number in the environsVersion field.  If
  25205. you request version 2, for instance, but only version 1 is available, the environsVersion
  25206. field will contain the value 1, and the result code envVersTooBig will be returned. 
  25207. This tells you that only the information for version 1 has been returned in SysEnvRec.
  25208.  
  25209. The MPW 2.0 interface files contain code, or “glue”, for System file versions earlier
  25210. than 4.1, as well as for the 64K and the Macintosh XL ROMs.  The glue checks for the
  25211. existence of the trap at runtime; if the call does not exist, the glue fills in all
  25212. fields of the record except systemVersion and returns the result code envNotPresent.
  25213.  
  25214. Assembly-language note:   As with the MoveHHi procedure, assembly-language
  25215.                           programmers using MPW should link with the glue and
  25216.                           execute
  25217.  
  25218.                               JSR SysEnvirons
  25219.  
  25220.                           If you’re using another development system, refer
  25221.                           to its documentation for details.
  25222.  
  25223. The machineType field returns one of the following constants:
  25224.  
  25225. CONST  envMachUnknown  = 0;    {new version of Macintosh--not covered }
  25226.                                { by this version of SysEnvirons}
  25227.        env512KE        = 1;    {Macintosh 512K enhanced}
  25228.        envMacPlus      = 2;    {Macintosh Plus}
  25229.        envSE           = 3;    {Macintosh SE}
  25230.        envMacII        = 4;    {Macintosh II}
  25231.        envMacIIx       = 5;    {Macintosh IIx}
  25232.        envMacIIcx      = 6;    {Macintosh IIcx}
  25233.        envSE30         = 7;    {Macintosh SE/30}
  25234.        envPortable     = 8;    {Macintosh Portable}
  25235.        envMacIIci      = 9;    {Macintosh IIci}
  25236.  
  25237. In addition to these, the glue for SysEnvirons may return one of the following:
  25238.  
  25239. CONST  envMac  = –1;    {Macintosh with 64K ROM}
  25240.        envXL   = –2;    {Macintosh XL}
  25241.  
  25242. The systemVersion field returns the version number of the System file represented as
  25243. two byte-long numbers, separated by a period. (It is not a fixed point number.) For
  25244. instance, System 4.1 returns $0410 or 04.10 in this field.
  25245. (Applications can use this for compare operations.)  If SysEnvirons is called while a
  25246. system earlier than System 4.1 is running, the glue will return a $0 in this field,
  25247. and the result code envNotPresent will be returned.
  25248.  
  25249. The processor field returns one of the following constants:
  25250.  
  25251. CONST  envCPUUnknown  = 0;    {new processor--not yet covered by this }
  25252.                               { version of SysEnvirons}
  25253.        env68000       = 1;    {MC68000 processor}
  25254.        env68010       = 2;    {MC68010 processor}
  25255.        env68020       = 3;    {MC68020 processor}
  25256.        env68030       = 4;    {MC68030 processor}
  25257.  
  25258. The hasFPU field tells whether or not a Motorola MC68881 floating-point coprocessor
  25259. unit is present.  (This field does not apply to third-party memory-mapped coprocessor
  25260. add-ons.)
  25261.  
  25262. The hasColorQD field tells whether or not Color QuickDraw is present.  It does not
  25263. indicate whether or not a color screen is present (high-level QuickDraw calls provide
  25264. this information).
  25265.  
  25266. The keyboardType field returns one of the following constants:
  25267.  
  25268. CONST  envUnknownKbd    = 0;    {Macintosh Plus keyboard with keypad}
  25269.        envMacKbd        = 1;    {Macintosh keyboard}
  25270.        envMacAndPad     = 2;    {Macintosh keyboard and keypad}
  25271.        envMacPlusKbd    = 3;    {Macintosh Plus keyboard}
  25272.        envAExtendKbd    = 4;    {Apple Extended keyboard}
  25273.        envStandADBKbd   = 5;    {Apple Standard keyboard}
  25274.        envPortADBKbd    = 6;    {Macintosh Portable keyboard}
  25275.        envPortISOADBKbd = 7;    {Macintosh Portable keyboard (ISO)}
  25276.        envStdISOADBKbd  = 8;    {Apple Standard keyboard (ISO)}
  25277.        envExtISOADBKbd  = 9;    {Apple Extended keyboard (ISO)}
  25278.  
  25279. If the Apple Desktop Bus™ is in use, this field returns the keyboard type of the
  25280. keyboard on which a keystroke was last made.
  25281.  
  25282. ATDrvrVersNum returns the version number of AppleTalk,  if it’s been loaded
  25283. (that is, if MPPOpen has been called); otherwise, 0 is returned in this field.
  25284.  
  25285. SysVRefNum returns the working directory reference number (or volume reference number)
  25286. of the directory that contains the currently open System file.
  25287.  
  25288. _______________________________________________________________________________
  25289.  
  25290. æKY SysEnvRec
  25291. æFp OSUtils.p
  25292. æT RECORD
  25293. æC SysEnvRec = RECORD
  25294.    environsVersion: INTEGER;
  25295.    machineType: INTEGER;
  25296.    systemVersion: INTEGER;
  25297.    processor: INTEGER;
  25298.    hasFPU: BOOLEAN;
  25299.    hasColorQD: BOOLEAN;
  25300.    keyBoardType: INTEGER;
  25301.    atDrvrVersNum: INTEGER;
  25302.    sysVRefNum: INTEGER;
  25303.    END;
  25304.  
  25305. The system environment record for version 1 of SysEnvirons contains the following
  25306. fields:
  25307.  
  25308. TYPE  SysEnvRec = RECORD
  25309.                     environsVersion:  INTEGER;
  25310.                     machineType:      INTEGER;
  25311.                     systemVersion:    INTEGER;
  25312.                     processor:        INTEGER;
  25313.                     hasFPU:           BOOLEAN;
  25314.                     hasColorQD:       BOOLEAN;
  25315.                     keyBoardType:     INTEGER;
  25316.                     atDrvrVersNum:    INTEGER;
  25317.                     sysVRefNum:       INTEGER
  25318.                   END;
  25319.  
  25320. New versions of the call will add fields to this record.  To distinguish between
  25321. different versions of the call, and thereby between the different sizes of records
  25322. they return, SysEnvirons returns its version number in the environsVersion field.  If
  25323. you request version 2, for instance, but only version 1 is available, the environsVersion
  25324. field will contain the value 1, and the result code envVersTooBig will be returned. 
  25325. This tells you that only the information for version 1 has been returned in SysEnvRec.
  25326.  
  25327. The MPW 2.0 interface files contain code, or “glue”, for System file versions earlier
  25328. than 4.1, as well as for the 64K and the Macintosh XL ROMs.  The glue checks for the
  25329. existence of the trap at runtime; if the call does not exist, the glue fills in all
  25330. fields of the record except systemVersion and returns the result code envNotPresent.
  25331.  
  25332. Assembly-language note:   As with the MoveHHi procedure, assembly-language
  25333.                           programmers using MPW should link with the glue and
  25334.                           execute
  25335.  
  25336.                               JSR SysEnvirons
  25337.  
  25338.                           If you’re using another development system, refer
  25339.                           to its documentation for details.
  25340.  
  25341. The machineType field returns one of the following constants:
  25342.  
  25343. CONST  envMachUnknown  = 0;    {new version of Macintosh--not covered }
  25344.                                { by this version of SysEnvirons}
  25345.        env512KE        = 1;    {Macintosh 512K enhanced}
  25346.        envMacPlus      = 2;    {Macintosh Plus}
  25347.        envSE           = 3;    {Macintosh SE}
  25348.        envMacII        = 4;    {Macintosh II}
  25349.        envMacIIx       = 5;    {Macintosh IIx}
  25350.        envMacIIcx      = 6;    {Macintosh IIcx}
  25351.        envSE30         = 7;    {Macintosh SE/30}
  25352.        envPortable     = 8;    {Macintosh Portable}
  25353.        envMacIIci      = 9;    {Macintosh IIci}
  25354.  
  25355. In addition to these, the glue for SysEnvirons may return one of the following:
  25356.  
  25357. CONST  envMac  = –1;    {Macintosh with 64K ROM}
  25358.        envXL   = –2;    {Macintosh XL}
  25359.  
  25360. The systemVersion field returns the version number of the System file represented as
  25361. two byte-long numbers, separated by a period. (It is not a fixed point number.) For
  25362. instance, System 4.1 returns $0410 or 04.10 in this field.
  25363. (Applications can use this for compare operations.)  If SysEnvirons is called while a
  25364. system earlier than System 4.1 is running, the glue will return a $0 in this field,
  25365. and the result code envNotPresent will be returned.
  25366.  
  25367. The processor field returns one of the following constants:
  25368.  
  25369. CONST  envCPUUnknown  = 0;    {new processor--not yet covered by this }
  25370.                               { version of SysEnvirons}
  25371.        env68000       = 1;    {MC68000 processor}
  25372.        env68010       = 2;    {MC68010 processor}
  25373.        env68020       = 3;    {MC68020 processor}
  25374.        env68030       = 4;    {MC68030 processor}
  25375.  
  25376. The hasFPU field tells whether or not a Motorola MC68881 floating-point coprocessor
  25377. unit is present.  (This field does not apply to third-party memory-mapped coprocessor
  25378. add-ons.)
  25379.  
  25380. The hasColorQD field tells whether or not Color QuickDraw is present.  It does not
  25381. indicate whether or not a color screen is present (high-level QuickDraw calls provide
  25382. this information).
  25383.  
  25384. The keyboardType field returns one of the following constants:
  25385.  
  25386. CONST  envUnknownKbd    = 0;    {Macintosh Plus keyboard with keypad}
  25387.        envMacKbd        = 1;    {Macintosh keyboard}
  25388.        envMacAndPad     = 2;    {Macintosh keyboard and keypad}
  25389.        envMacPlusKbd    = 3;    {Macintosh Plus keyboard}
  25390.        envAExtendKbd    = 4;    {Apple Extended keyboard}
  25391.        envStandADBKbd   = 5;    {Apple Standard keyboard}
  25392.        envPortADBKbd    = 6;    {Macintosh Portable keyboard}
  25393.        envPortISOADBKbd = 7;    {Macintosh Portable keyboard (ISO)}
  25394.        envStdISOADBKbd  = 8;    {Apple Standard keyboard (ISO)}
  25395.        envExtISOADBKbd  = 9;    {Apple Extended keyboard (ISO)}
  25396.  
  25397. If the Apple Desktop Bus™ is in use, this field returns the keyboard type of the
  25398. keyboard on which a keystroke was last made.
  25399.  
  25400. ATDrvrVersNum returns the version number of AppleTalk,  if it’s been loaded
  25401. (that is, if MPPOpen has been called); otherwise, 0 is returned in this field.
  25402.  
  25403. SysVRefNum returns the working directory reference number (or volume reference number)
  25404. of the directory that contains the currently open System file.
  25405.  
  25406. æKY TrapType,OSTrap,ToolTrap
  25407. æFp OSUtils.p
  25408. æC TrapType = (OSTrap,ToolTrap);
  25409.  
  25410. æKY UprString
  25411. æFp OSUtils.p
  25412. æT PROCEDURE
  25413. æTN $A054
  25414. æD PROCEDURE UprString(VAR theString: Str255;diacSens: BOOLEAN);
  25415. æDT UprString(theString,diacSens);
  25416. æRI UprString procedure II-377
  25417. æC 
  25418. Assembly-language note:  The trap macros for these utility routines have
  25419.                          optional arguments corresponding to the Pascal flags
  25420.                          passed to the routines. When present, such an argument
  25421.                          sets a certain bit of the routine trap word; this is
  25422.                          equivalent to setting the corresponding Pascal flag to
  25423.                          either TRUE or FALSE, depending on the flag. The trap
  25424.                          macros for these routines are listed with all the
  25425.                          possible permutations of arguments. Whichever
  25426.                          permutation you use, you must type it exactly as shown.
  25427.                          (The syntax shown applies to the Lisa Workshop
  25428.                          Assembler; programmers using another development
  25429.                          system should consult its documentation for the proper
  25430.                          syntax.)
  25431.  
  25432. Trap macro  _UprString
  25433.             _UprString ,MARKS (sets bit 9, for diacSens=FALSE)
  25434. On entry    A0:  pointer to first character of string
  25435.             D0:  length of string (word)
  25436. On exit     A0:  pointer to first character of string
  25437.  
  25438. UprString converts any lowercase letters in the given string to uppercase, returning
  25439. the converted string in theString. In addition, diacritical marks are stripped from
  25440. the string if diacSens is FALSE.
  25441.  
  25442. æKY useAsync
  25443. æFp OSUtils.p
  25444. æC useAsync = 2;
  25445.  
  25446. æKY useATalk
  25447. æFp OSUtils.p
  25448. æC useATalk = 1;
  25449.  
  25450. æKY useExtClk
  25451. æFp OSUtils.p
  25452. æC useExtClk = 3; {Externally clocked}
  25453.  
  25454. æKY useFree
  25455. æFp OSUtils.p
  25456. æC useFree = 0;
  25457.  
  25458. æKY useMIDI
  25459. æFp OSUtils.p
  25460. æC useMIDI = 4;
  25461.  
  25462. æKY WriteParam
  25463. æFp OSUtils.p
  25464. æT FUNCTION
  25465. æTN $A038
  25466. æD FUNCTION WriteParam: OSErr;
  25467. æDT myVariable := WriteParam;
  25468. æRI WriteParam function II-382
  25469. æC 
  25470. Trap macro  _WriteParam
  25471. On entry    A0:    SysParam (pointer)
  25472.             D0:    MinusOne (long word)
  25473.                    (You have to pass the values of these global variables for
  25474.                    historical reasons.)
  25475. On exit     D0:    result code (word)
  25476.  
  25477. WriteParam writes the low-memory copy of parameter RAM to the clock chip. You should
  25478. previously have called GetSysPPtr and changed selected values as desired.
  25479.  
  25480. WriteParam also attempts to verify the values written by reading them back in and
  25481. comparing them to the values in the low-memory copy.
  25482.  
  25483. Note:  If you’ve accidentally written incorrect values into parameter RAM,
  25484.        the system may not be able to start up. If this happens, you can reset
  25485.        parameter RAM by removing the battery, letting the Macintosh sit turned
  25486.        off for about five minutes, and then putting the battery back in.
  25487.  
  25488. Result codes    noErr      No error
  25489.                 prWrErr    Parameter RAM written did not verify
  25490.  
  25491.  
  25492. æKY Packages.p
  25493. æKL InitAllPacks
  25494. InitPack
  25495. IUCompString
  25496. IUDatePString
  25497. IUDateString
  25498. IUEqualString
  25499. IUGetIntl
  25500. IUMagIDString
  25501. IUMagString
  25502. IUMetric
  25503. IUSetIntl
  25504. IUTimePString
  25505. IUTimeString
  25506. NumToString
  25507. SFGetFile
  25508. SFPGetFile
  25509. SFPutFile
  25510. StringToNum
  25511.  
  25512. abbrevDate
  25513. bdConv
  25514. century
  25515. currLeadingZ
  25516. currNegSym
  25517. currSymLead
  25518. currTrailingZ
  25519. DateForm
  25520. dayLdingZ
  25521. dmy
  25522. dskInit
  25523. dym
  25524. flPoint
  25525. getCancel
  25526. getDlgID
  25527. getDrive
  25528. getEject
  25529. getNmList
  25530. getOpen
  25531. getScroll
  25532. hrLeadingZ
  25533. Intl0Hndl
  25534. Intl0Ptr
  25535. Intl0Rec
  25536. Intl1Hndl
  25537. Intl1Ptr
  25538. Intl1Rec
  25539. intUtil
  25540. listMgr
  25541. longDate
  25542. longDay
  25543. longMonth
  25544. longWeek
  25545. longYear
  25546. maxCountry
  25547. mdy
  25548. minCountry
  25549. minLeadingZ
  25550. mntLdingZ
  25551. myd
  25552. putCancel
  25553. putDlgID
  25554. putDrive
  25555. putEject
  25556. putName
  25557. putSave
  25558. secLeadingZ
  25559. SFReply
  25560. SFTypeList
  25561. shortDate
  25562. stdFile
  25563. supDay
  25564. supMonth
  25565. supWeek
  25566. supYear
  25567. trFunc
  25568. verArabia
  25569. verAustralia
  25570. verBelgiumLux
  25571. verBritain
  25572. verChina
  25573. verCyprus
  25574. verDenmark
  25575. verFinland
  25576. verFrance
  25577. verFrCanada
  25578. verFrSwiss
  25579. verGermany
  25580. verGreece
  25581. verGrSwiss
  25582. verIceland
  25583. verIreland
  25584. verIsrael
  25585. verItaly
  25586. verJapan
  25587. verKorea
  25588. verMalta
  25589. verNetherlands
  25590. verNorway
  25591. verPortugal
  25592. verSpain
  25593. verSweden
  25594. verTaiwan
  25595. verThailand
  25596. verTurkey
  25597. verUS
  25598. verYugoslavia
  25599. ydm
  25600. ymd
  25601. zeroCycle
  25602.  
  25603. æKY Intl0Hndl,Intl0Ptr,Intl0Rec
  25604. æFp Packages.p
  25605. æT TYPE
  25606. æC Intl0Ptr = ^Intl0Rec;
  25607. Intl0Hndl = ^Intl0Ptr;
  25608. Intl0Rec = PACKED RECORD
  25609.    decimalPt: CHAR;                        {decimal point character}
  25610.    thousSep: CHAR;                         {thousands separator}
  25611.    listSep: CHAR;                          {list separator}
  25612.    currSym1: CHAR;                         {currency symbol}
  25613.    currSym2: CHAR;
  25614.    currSym3: CHAR;
  25615.    currFmt: Byte;                          {currency format}
  25616.    dateOrder: Byte;                        {order of short date elements}
  25617.    shrtDateFmt: Byte;                      {short date format}
  25618.    dateSep: CHAR;                          {date separator}
  25619.    timeCycle: Byte;                        {0 if 24-hour cycle, 255 if 12-hour}
  25620.    timeFmt: Byte;                          {time format}
  25621.    mornStr: PACKED ARRAY [1..4] OF CHAR;   {trailing string for first 12-hour cycle}
  25622.    eveStr: PACKED ARRAY [1..4] OF CHAR;    {trailing string for last 12-hour cycle}
  25623.    timeSep: CHAR;                          {time separator}
  25624.    time1Suff: CHAR;                        {trailing string for 24-hour cycle}
  25625.    time2Suff: CHAR;
  25626.    time3Suff: CHAR;
  25627.    time4Suff: CHAR;
  25628.    time5Suff: CHAR;
  25629.    time6Suff: CHAR;
  25630.    time7Suff: CHAR;
  25631.    time8Suff: CHAR;
  25632.    metricSys: Byte;                        {255 if metric, 0 if not}
  25633.    intl0Vers: INTEGER;                     {version information}
  25634.    END;
  25635.  
  25636. æKY Intl1Hndl,Intl1Ptr,Intl1Rec
  25637. æFp Packages.p
  25638. æT TYPE
  25639. æC Intl1Ptr = ^Intl1Rec;
  25640. Intl1Hndl = ^Intl1Ptr;
  25641. Intl1Rec = PACKED RECORD
  25642.    days: ARRAY [1..7] OF Str15;            {day names}
  25643.    months: ARRAY [1..12] OF Str15;         {month names}
  25644.    suppressDay: Byte;                      {0 for day name, 255 for none}
  25645.    lngDateFmt: Byte;                       {order of long date elements}
  25646.    dayLeading0: Byte;                      {255 for leading 0 in day number}
  25647.    abbrLen: Byte;                          {length for abbreviating names}
  25648.    st0: PACKED ARRAY [1..4] OF CHAR;       {strings for long date format}
  25649.    st1: PACKED ARRAY [1..4] OF CHAR;
  25650.    st2: PACKED ARRAY [1..4] OF CHAR;
  25651.    st3: PACKED ARRAY [1..4] OF CHAR;
  25652.    st4: PACKED ARRAY [1..4] OF CHAR;
  25653.    intl1Vers: INTEGER;                     {version information}
  25654.    localRtn: ARRAY [0..0] OF INTEGER;      {routine for localizing string comparison}
  25655.    END;
  25656.  
  25657. æKY century
  25658. æFp Packages.p
  25659. æC century = 128;
  25660.  
  25661. æKY currLeadingZ
  25662. æFp Packages.p
  25663. æC currLeadingZ = 128;
  25664.  
  25665. æKY currNegSym
  25666. æFp Packages.p
  25667. æC currNegSym = 32;
  25668.  
  25669. æKY currSymLead
  25670. æFp Packages.p
  25671. æC currSymLead = 16;
  25672.  
  25673. æKY currTrailingZ
  25674. æFp Packages.p
  25675. æC currTrailingZ = 64;
  25676.  
  25677. æKY DateForm,shortDate,longDate,abbrevDate
  25678. æFp Packages.p
  25679. æC DateForm = (shortDate,longDate,abbrevDate);
  25680.  
  25681. æKY dayLdingZ
  25682. æFp Packages.p
  25683. æC dayLdingZ = 32;
  25684.  
  25685. æKY dmy
  25686. æFp Packages.p
  25687. æC dmy = 1;
  25688.  
  25689. æKY dym
  25690. æFp Packages.p
  25691. æC dym = 4;
  25692.  
  25693. æKY getCancel
  25694. æFp Packages.p
  25695. æC getCancel = 3;
  25696.  
  25697. æKY getDlgID
  25698. æFp Packages.p
  25699. æC getDlgID = -4000;
  25700.  
  25701. æKY getDrive
  25702. æFp Packages.p
  25703. æC getDrive = 6;
  25704.  
  25705. æKY getEject
  25706. æFp Packages.p
  25707. æC getEject = 5;
  25708.  
  25709. æKY getNmList
  25710. æFp Packages.p
  25711. æC getNmList = 7;
  25712.  
  25713. æKY getOpen
  25714. æFp Packages.p
  25715. æC getOpen = 1;
  25716.  
  25717. æKY getScroll
  25718. æFp Packages.p
  25719. æC getScroll = 8;
  25720.  
  25721. æKY hrLeadingZ
  25722. æFp Packages.p
  25723. æC hrLeadingZ = 128;
  25724.  
  25725. æKY InitAllPacks
  25726. æFp Packages.p
  25727. æT PROCEDURE
  25728. æTN $A9E6
  25729. æD PROCEDURE InitAllPacks;
  25730. æDT InitAllPacks;
  25731. æMM   
  25732. æRI InitAllPacks procedure I-484
  25733. æC 
  25734. InitAllPacks enables you to use all Macintosh packages (as though InitPack were
  25735. called for each one). It will already have been called when your application starts
  25736. up.
  25737.  
  25738. æKY InitPack
  25739. æFp Packages.p
  25740. æT PROCEDURE
  25741. æTN $A9E5
  25742. æD PROCEDURE InitPack(packID: INTEGER);
  25743. æDT InitPack(packID);
  25744. æMM   
  25745. æRI InitPack procedure I-484
  25746. æC  
  25747. InitPack enables you to use the package specified by packID, which is the package’s
  25748. resource ID. (It gets a handle that will be used later to read the package into
  25749. memory.)
  25750.  
  25751. æKY IUCompString
  25752. æFp Packages.p
  25753. æT FUNCTION
  25754. æD FUNCTION IUCompString(aStr: Str255;bStr: Str255): INTEGER;
  25755. æDT myVariable := IUCompString(aStr,bStr);
  25756. æMM   
  25757. æRI IUCompString function I-506, N58-1
  25758. æC     IUCompString compares aStr and bStr as described above under
  25759. "International String Comparison", taking both primary and secondary
  25760. ordering into consideration. It returns one of the values listed
  25761. below.
  25762.  
  25763.       Result   Meaning                           Example
  25764.                                               aStr     bStr
  25765.        -1       aStr is less than bStr       'Ab'     'ab'
  25766.         0       aStr equals bStr             'Ab'     'Ab'
  25767.         1       aStr is greater than bStr    'Ac'     'ab'
  25768.  
  25769. æKY IUDatePString
  25770. æFp Packages.p
  25771. æT PROCEDURE
  25772. æTN $A9ED
  25773. æD PROCEDURE IUDatePString(dateTime: LONGINT;longFlag: DateForm;VAR result: Str255;
  25774.     intlParam: Handle);
  25775. æDT IUDatePString(dateTime,longFlag,result,intlParam);
  25776. æMM   
  25777. æRI IUDatePString procedure I-505
  25778. æC     IUDatePString is the same as IUDateString except that it determines
  25779. the exact format of the date from the resource whose handle is passed in
  25780. intlParam, overriding the resource that would otherwise be used.
  25781.  
  25782. æKY IUDateString
  25783. æFp Packages.p
  25784. æT PROCEDURE
  25785. æTN $A9ED
  25786. æD PROCEDURE IUDateString(dateTime: LONGINT;longFlag: DateForm;VAR result: Str255);
  25787. æDT IUDateString(dateTime,longFlag,result);
  25788. æMM   
  25789. æRI IUDateString procedure I-504
  25790. æC     Given a date and time as returned by the Operating System Utility
  25791. routine ReadDateTime, IUDateString returns in the result parameter a
  25792. string that represents the corresponding date. The form parameter has
  25793. the following data type:
  25794.  
  25795.        TYPE DateForm = (shortDate,longDate,abbrevDate);
  25796.  
  25797.     ShortDate requests the short date format, longDate the long date,
  25798. and abbrevDate the abbreviated long date. IUDateString determines the
  25799. exact format from international resource 0 for the short date or 1 for
  25800. the long date. See Figure I-1 above for examples of the standard
  25801. formats. Notice that the short date contains a space in place of  a
  25802. leading zero when the format specifies "no leading zero", so the length
  25803. of the result is always the same for short dates.
  25804.  
  25805.     If the abbreviated long date is requested and the abbreviation
  25806. length in international resource 1 is greater than the actual length of
  25807. the name being abbreviated, IUDateString fills the abbreviation with NULL
  25808. characters; the abbreviation length should not be greater than 15, the
  25809. maximum name length.
  25810. æFp PROCEDURE
  25811. æD     Given a date and time as returned by
  25812. æMM   
  25813. æRI IUDateString procedure I-504
  25814.  
  25815. æKY IUEqualString
  25816. æFp Packages.p
  25817. æT FUNCTION
  25818. æD FUNCTION IUEqualString(aStr: Str255;bStr: Str255): INTEGER;
  25819. æDT myVariable := IUEqualString(aStr,bStr);
  25820. æMM   
  25821. æRI IUEqualString function I-506, N58-1
  25822. æC     IUEqualString compares aStr and bStr for equality without regard
  25823. for secondary ordering, as described above under "international String
  25824. Comparison". If the strings are equal, it returns 0; otherwise, it
  25825. returns 1. For example, if the strings are 'Rose' and 'rose',
  25826. IUEqualString considers them equal and returns 0.
  25827.  
  25828. Note:  
  25829.  
  25830.     See also EqualString in the Operating System Utilities manual.
  25831. æMM   
  25832. æRI IUEqualString function I-506, N58-1
  25833.  
  25834. æKY IUGetIntl
  25835. æFp Packages.p
  25836. æT FUNCTION
  25837. æD FUNCTION IUGetIntl(theID: INTEGER): Handle;
  25838. æDT myVariable := IUGetIntl(theID);
  25839. æMM 
  25840. æRT 153
  25841. æRI IUGetIntl function I-505
  25842. æC     IUGetIntl returns a handle to the international resource numbered
  25843. theID (0 or 1). It calls the Resource Manager function
  25844. GetResource('INTL',theID). For example, if you want to access
  25845. individual fields of international resource 0, you can do the
  25846. following:
  25847.  
  25848.      VAR myHndl: Handle;
  25849.          int0: Intl0Hndl;
  25850.      ...
  25851.      myHndl := IUGetIntl(0);
  25852.      int0 := POINTER(ORD(myHndl));
  25853.  
  25854. æKY IUMagIDString
  25855. æFp Packages.p
  25856. æT FUNCTION
  25857. æTN $A9ED
  25858. æD FUNCTION IUMagIDString(aPtr: Ptr;bPtr: Ptr;aLen: INTEGER;bLen: INTEGER): INTEGER;
  25859. æDT myVariable := IUMagIDString(aPtr,bPtr,aLen,bLen);
  25860. æMM   
  25861. æRI IUMagIDString function I-507, N58-1
  25862. æC IUMagIDString is the same as IUEqualString (above) except that instead of 
  25863. comparing two Pascal strings, it compares the string defined by aPtr and aLen to 
  25864. the string defined by bPtr and bLen.  The pointer points to the first character of the 
  25865. string (any byte in memory, not necessarily word-aligned), and the length specifies 
  25866. the number of characters in the string.
  25867.  
  25868. æKY IUMagString
  25869. æFp Packages.p
  25870. æT FUNCTION
  25871. æTN $A9ED
  25872. æD FUNCTION IUMagString(aPtr: Ptr;bPtr: Ptr;aLen: INTEGER;bLen: INTEGER): INTEGER;
  25873. æDT myVariable := IUMagString(aPtr,bPtr,aLen,bLen);
  25874. æMM   
  25875. æRI IUMagString function I-506, N58-1
  25876. æC     IUMagString is the same as IUCompString (above) except that instead
  25877. of comparing two Pascal strings, it compares the string defined by aPtr
  25878. and aLen to the string defined by bPtr and bLen. The pointer points to
  25879. the first character of the string (any byte in memory, not necessarily
  25880. word-aligned), and the length specifies the number of characters in the
  25881. string.
  25882.  
  25883. æKY IUMetric
  25884. æFp Packages.p
  25885. æT FUNCTION
  25886. æTN $A9ED
  25887. æD FUNCTION IUMetric: BOOLEAN;
  25888. æDT myVariable := IUMetric;
  25889. æMM   
  25890. æRI IUMetric function I-505
  25891. æC     If international resource 0 specifies that the metric system is to
  25892. be used, IUMetric returns TRUE; otherwise, it returns FALSE.
  25893.  
  25894. æKY IUSetIntl
  25895. æFp Packages.p
  25896. æT PROCEDURE
  25897. æTN $A9ED
  25898. æD PROCEDURE IUSetIntl(refNum: INTEGER;theID: INTEGER;intlParam: Handle);
  25899. æDT IUSetIntl(refNum,theID,intlParam);
  25900. æMM   
  25901. æRI IUSetIntl procedure I-506
  25902. æC     In the resource file having the reference number refNum, IUSetIntl
  25903. sets the international resource numbered theID (0 or 1) to the data
  25904. pointed to by intlParam. The data may be either an existing resource
  25905. or data that hasn't yet been written to a resource file. IUSetIntl
  25906. adds the resource to the specified file or replaces the resource if it's
  25907. already there.
  25908. æMM   
  25909. æRI IUTimePString procedure I-505
  25910.  
  25911. æKY IUTimePString
  25912. æFp Packages.p
  25913. æT PROCEDURE
  25914. æTN $A9ED
  25915. æD PROCEDURE IUTimePString(dateTime: LONGINT;wantSeconds: BOOLEAN;VAR result: Str255;
  25916.     intlParam: Handle);
  25917. æDT IUTimePString(dateTime,wantSeconds,result,intlParam);
  25918. æMM   
  25919. æRI IUTimePString procedure I-505
  25920. æC     IUTimePString is the same as IUTimeString except that it determines
  25921. the time format from the resource whose handle is passed in intlParam,
  25922. overriding the resource that would otherwise be used.
  25923. æMM   
  25924. æRI IUTimeString procedure I-505
  25925.  
  25926. æKY IUTimeString
  25927. æFp Packages.p
  25928. æT PROCEDURE
  25929. æTN $A9ED
  25930. æD PROCEDURE IUTimeString(dateTime: LONGINT;wantSeconds: BOOLEAN;VAR result: Str255);
  25931. æDT IUTimeString(dateTime,wantSeconds,result);
  25932. æMM   
  25933. æRI IUTimeString procedure I-505
  25934. æC     Given a date and time as returned by the Operating System Utility
  25935. routine ReadDateTime, IUTimeString returns in the result parameter a
  25936. string that represents the corresponding time of day. If wantSeconds
  25937. is TRUE, seconds are included in the time; otherwise, only the hour and
  25938. minute are included. IUTimeSting determines the time format from
  25939. international resource 0. See Figure I-1 above for examples of the
  25940. standard formats. Notice that the time contains a space in place of a
  25941. leading zero when the format specifies "no leading zero", so the length
  25942. of the result is always the same.
  25943.  
  25944. æKY listMgr,dskInit,stdFile,flPoint,trFunc,intUtil,bdConv
  25945. æFp Packages.p
  25946. æC 
  25947.  
  25948.   { Resource IDs for packages }
  25949.  
  25950.   listMgr    = 0;    {List Manager}
  25951.   dskInit    = 2;    {Disk Initialization}
  25952.   stdFile    = 3;    {Standard File}
  25953.   flPoint    = 4;    {Floating-Point Arithmetic}
  25954.   trFunct    = 5;    {Transcendental Functions}
  25955.   intUtil    = 6;    {International Utilities}
  25956.   bdConv     = 7;    {Binary-Decimal Conversion}
  25957.  
  25958. _______________________________________________________________________________
  25959.  
  25960. »ABOUT PACKAGES
  25961. _______________________________________________________________________________
  25962.  
  25963. Packages are sets of data types and routines that are stored as resources and brought
  25964. into memory only when needed. They serve as extensions to the Toolbox and Operating
  25965. System, for the most part performing less common operations.
  25966.  
  25967. The Macintosh packages, which are stored in the system resource file, include the
  25968. following:
  25969.  
  25970.   •  The Standard File Package, for presenting the standard user interface
  25971.      when a file is to be saved or opened.
  25972.   •  The Disk Initialization Package, for initializing and naming new disks.
  25973.      This package is called by the Standard File Package; you’ll only need
  25974.      to call it in nonstandard situations.
  25975.   •  The International Utilities Package, for accessing country-dependent
  25976.      information such as the formats for numbers, currency, dates, and times.
  25977.   •  The Binary-Decimal Conversion Package, for converting integers to
  25978.      decimal strings and vice versa.
  25979.   •  The Floating-Point Arithmetic Package, which supports extended-precision
  25980.      arithmetic according to IEEE Standard 754.
  25981.   •  The Transcendental Functions Package, which contains trigonometric,
  25982.      logarithmic, exponential, and financial functions, as well as a random
  25983.      number generator.
  25984.   •  The List Manager Package, for creating, displaying, and manipulating lists.
  25985.  
  25986. The following Macintosh packages, previously stored only in the system resource file,
  25987. are now also found in the 128K ROM:
  25988.  
  25989.   •  The Binary-Decimal Conversion Package
  25990.   •  The Floating-Point Arithmetic Package
  25991.   •  The Transcendental Functions Package
  25992.  
  25993. For compatibility with the 64K ROM, the above resources are still stored in the
  25994. system resource file. The system resource file contains the following additional
  25995. packages as well:
  25996.  
  25997.   •  The List Manager Package, for creating, displaying, and manipulating lists.
  25998.   •  The Standard File Package.
  25999.   •  The Disk Initialization Package
  26000.   •  The International Utilities Package
  26001.  
  26002. Packages have the resource type 'PACK' and the following resource IDs:
  26003.  
  26004. CONST  listMgr = 0;    {List Manager}
  26005.        dskInit = 2;    {Disk Initialization}
  26006.        stdFile = 3;    {Standard File}
  26007.        flPoint = 4;    {Floating-Point Arithmetic}
  26008.        trFunc  = 5;    {Transcendental Functions}
  26009.        intUtil = 6;    {International Utilities}
  26010.        bdConv  = 7;    {Binary-Decimal Conversion}
  26011.  
  26012. The Package Manager has been extended to allow for eight additional packages. All
  26013. packages are reserved for use by Apple.
  26014.  
  26015. Assembly-language note:  Just as for the routines in ROM, you can invoke a
  26016.                          package routine with a macro that has the same name
  26017.                          as the routine preceded by an underscore. These
  26018.                          macros, however, aren’t trap macros themselves;
  26019.                          instead, they expand to invoke the trap macro _PackN,
  26020.                          where N is the resource ID of the package. The package
  26021.                          determines which routine to execute from the routine
  26022.                          selector, an integer that’s passed to it in a word on
  26023.                          the stack. For example, the routine selector for the
  26024.                          Standard File Package procedure SFPutFile is 1, so
  26025.                          invoking the macro _SFPutFile pushes 1 onto the stack
  26026.                          and invokes _Pack3. The routines in the Floating-Point
  26027.                          Arithmetic and Transcendental Functions packages also
  26028.                          invoke a trap macro of the form _PackN, but the
  26029.                          mechanism through which they’re called is somewhat
  26030.                          different, as explained in the chapter describing
  26031.                          those packages.
  26032.  
  26033. æKY longDay
  26034. æFp Packages.p
  26035. æC longDay = 0; {day of the month}
  26036.  
  26037. æKY longMonth
  26038. æFp Packages.p
  26039. æC longMonth = 2; {month of the year}
  26040.  
  26041. æKY longWeek
  26042. æFp Packages.p
  26043. æC longWeek = 1; {day of the week}
  26044.  
  26045. æKY longYear
  26046. æFp Packages.p
  26047. æC longYear = 3; {year}
  26048.  
  26049. æKY maxCountry
  26050. æFp Packages.p
  26051. æC maxCountry = verThailand;
  26052.  
  26053. æKY mdy
  26054. æFp Packages.p
  26055. æC mdy = 0;
  26056.  
  26057. æKY minCountry
  26058. æFp Packages.p
  26059. æC minCountry = verUS;
  26060.  
  26061. æKY minLeadingZ
  26062. æFp Packages.p
  26063. æC minLeadingZ = 64;
  26064.  
  26065. æKY mntLdingZ
  26066. æFp Packages.p
  26067. æC mntLdingZ = 64;
  26068.  
  26069. æKY myd
  26070. æFp Packages.p
  26071. æC myd = 3;
  26072.  
  26073. æKY NumToString
  26074. æFp Packages.p
  26075. æT PROCEDURE
  26076. æTN $A9EE
  26077. æD PROCEDURE NumToString(theNum: LONGINT;VAR theString: Str255);
  26078. æDT NumToString(theNum,theString);
  26079. æMM   
  26080. æRI NumToString procedure  I-489
  26081. æC 
  26082. _____________________________________________________________________________________
  26083.  
  26084. Trap macro     _NumToString
  26085.  
  26086. On entry        A0:  pointer to theString (length byte followed
  26087.                      by characters)
  26088.  
  26089.                 D0:  theNum (long integer)
  26090.  
  26091. On exit         A0:  pointer to theString
  26092.  
  26093. _____________________________________________________________________________________
  26094.  
  26095. NumToString converts theNum to a string that represents its decimal
  26096. value, and returns the result in theString. If the value is negative,
  26097. the string begins with a minus sign; otherwise, the sign is omitted.
  26098. Leading zeroes are suppressed, except that the value 0 produces '0'.
  26099. For example:
  26100.  
  26101.      theNum          theString
  26102.       12              '12'
  26103.      -23             '-23'
  26104.        0              '0'
  26105. æMM   
  26106. æRI NumToString procedure  I-489
  26107.  
  26108. æKY putCancel
  26109. æFp Packages.p
  26110. æC putCancel = 2;
  26111.  
  26112. æKY putDlgID
  26113. æFp Packages.p
  26114. æC putDlgID = -3999;
  26115.  
  26116. æKY putDrive
  26117. æFp Packages.p
  26118. æC putDrive = 6;
  26119.  
  26120. æKY putEject
  26121. æFp Packages.p
  26122. æC putEject = 5;
  26123.  
  26124. æKY putName
  26125. æFp Packages.p
  26126. æC putName = 7;
  26127.  
  26128. æKY putSave
  26129. æFp Packages.p
  26130. æC putSave = 1;
  26131.  
  26132. æKY secLeadingZ
  26133. æFp Packages.p
  26134. æC secLeadingZ = 32;
  26135.  
  26136. æKY SFGetFile
  26137. æFp Packages.p
  26138. æT PROCEDURE
  26139. æTN $A9EA
  26140. æD PROCEDURE SFGetFile(where: Point;prompt: Str255;fileFilter: ProcPtr;
  26141.     numTypes: INTEGER;typeList: SFTypeList;dlgHook: ProcPtr;VAR reply: SFReply);
  26142. æDT SFGetFile(where,prompt,fileFilter,numTypes,typeList,dlgHook,reply);
  26143. æRT 47, 77, 80, 107, 205
  26144. æRI SFGetFile procedure I-523, N47, N77-1, N80-1, N99, P-125, 162, 181
  26145. æC     SFGetFile displays a dialog box listing the names of a specific
  26146. group of files from which the user can select one to be opened (as
  26147. during an Open command). It then repeatedly gets and handles events
  26148. until the user either confirms the command after choosing a file name or
  26149. aborts the command by clicking Cancel in the dialog. It reports the
  26150. user's reply by filling the fields of the reply record specified by the
  26151. reply parameter, as described above under "Using the Standard File
  26152. Package".
  26153.  
  26154.     The general appearance of the standard SFGetFile dialog box is shown
  26155. in Figure S-5. File names are sorted in order of the ASCII codes of
  26156. their characters, ignoring diacritical marks and mapping lowercase
  26157. characters to their uppercase equivalents. If there are more file names
  26158. than can be displayed at one time, the scroll bar is active; otherwise,
  26159. the scroll bar is inactive.
  26160.  
  26161.     The where parameter specifies the  location of the top left corner
  26162. of the dialog box in global coordinates. The prompt parameter is
  26163. ignored; it's there for historical purposes only.
  26164.  
  26165.     The fileFilter, numTypes, and typeList parameters determine which
  26166. files appear in the dialog box. SFGetFile first looks at numTypes and
  26167. typeList to determine what types of files to display, then it executes
  26168. the function pointed to by fileFilter (if any) to do additional
  26169. filtering on which files to display. File types are discussed in the
  26170. manual THE STRUCTURE OF A MACINTOSH APPLICATION. For example, if the
  26171. application is concerned only with pictures, you won't want to display
  26172. the names of any text files.
  26173.  
  26174.     Pass -1 for numTypes to display all types of files; otherwise, pass
  26175. the number of file types you want to display, and pass the types
  26176. themselves in typeList. The SFTypeList data type is defined as follows:
  26177.  
  26178.          TYPE SFTypeList = ARRAY [0..3] OF OSTYPE;
  26179.  
  26180. Note:  
  26181.  
  26182.     This array is declared for a reasonable maximum number of
  26183.     types (four). If you need to specify more than four
  26184.     types, declare your own array type with the desired
  26185.     number of entries (and use the @ operator to pass a
  26186.     pointer to it).
  26187.  
  26188.     If fileFilter isn't NIL, SFGetFile executes the function it points
  26189. to for each file, to determine whether the file should be displayed.
  26190. The fileFilter function has one parameter and returns a Boolean value.
  26191. For example:
  26192.  
  26193.          FUNCTION MyFileFilter (paramBlock: ParmBlkPtr) : BOOLEAN;
  26194.  
  26195.     SFGetFile passes this function the file information it gets by
  26196. calling the File Manager procedure PBGetFInfo. The function selects
  26197. which files should appear in the dialog by returning FALSE for every
  26198. file that should be shown and TRUE for every file that shouldn't be
  26199. shown.
  26200.  
  26201. Note:  
  26202.  
  26203.     As described in the File Manager manual, a flag can be
  26204.     set that tells the Finder not to display a particular
  26205.     file's icon on the desktop; this has no effect on whether
  26206.     SFGetFile will list the file name.
  26207.  
  26208.     If you want to use the standard SFGetFile dialog box, pass NIL for
  26209. dlgHook; otherwise, see the information for advanced programmers below.
  26210.  
  26211.     Like SFPutFile, SFGetFile repeatedly calls the Dialog Manager
  26212. procedure ModalDialog. When an event involving an enabled dialog item
  26213. occurs, ModalDialog handles the event and returns the item number, and
  26214. SFGetFile responds as follows:
  26215.  
  26216.    • If the Eject or Drive button is clicked, or a disk is inserted,
  26217.      SFGetFile responds as described above under "About the Standard
  26218.      File Package".
  26219.  
  26220.    • If clicking or dragging occurs in the scroll bar, the contents of
  26221.      the dialog box are redrawn accordingly.
  26222.  
  26223.    • If a file name is clicked, it's selected and stored in the fName
  26224.      field of the reply record. (SFGetFile keeps track of whether a
  26225.      file name is currently selected, and makes the Open button
  26226.      inactive if not.)
  26227.  
  26228.    • If the Open button is clicked, SFGetFile returns control to the
  26229.      application with the first field of the reply record set to TRUE.
  26230.  
  26231.    • If a file name is double-clicked, SFGetFile responds as if the
  26232.      user clicked the file name and then the Open button.
  26233.  
  26234.    • If the Cancel button in the dialog is clicked, SFGetFile returns
  26235.      control to the application with the first field of the reply
  26236.      record set to FALSE.
  26237.  
  26238.     If a key (other than a modifier key) is pressed, SFGetFile selects
  26239. the first file name starting with the character typed. If no file name
  26240. starts with that character, it selects the first file name starting
  26241. with a character whose ASCII code is greater than the character typed.
  26242.  
  26243. Advanced programmers:  You can create your own dialog box rather than
  26244. use the  standard SFGetFile dialog. To do this, you must provide your
  26245. own dialog template and store it in your application's resource file
  26246. with the same resource ID that the standard template has in the system
  26247. resource file:
  26248.  
  26249.         CONST getDlgID = -4000;   {SFGetFile dialog template ID}
  26250.  
  26251. Note:  
  26252.  
  26253.     The SFPGetFile procedure, described below, lets you use
  26254.     any resource ID for your nonstandard dialog box.
  26255.  
  26256.  
  26257.     Your dialog template must specify that the dialog window be
  26258. invisible, and your dialog must contain all the standard items, as
  26259. listed below. The appearance and location of these items in your dialog
  26260. may be different. You can make an item "invisible" by giving it a
  26261. display rectangle that's off the screen. The display rectangle for each
  26262. in the standard dialog box is given below. The rectangle for the
  26263. standard dialog box itself is (0,0,348,136).
  26264.  
  26265.  Item Number    Item                     Standard display rectangle
  26266.     1         Open button                     (152,28,232,46)
  26267.     2         Invisible button                (1152,59,1232,77)
  26268.     3         Cancel button                   (152,90,232,108)
  26269.     4         UserItem for disk name          (248,28,344,46)
  26270.     5         Eject button                    (256,59,336,77)
  26271.     6         Drive button                    (256,90,336,108)
  26272.     7         UserItem for file name list     (12,11,125,125)
  26273.     8         UserItem for scroll bar         (124,11,140,125)
  26274.     9         UserItem for gray line          (244,20,245,116)
  26275.    10         Invisible text (statText)       (1044,20,1145,116)
  26276.  
  26277.     If your dialog has additional items beyond the standard ones, or if
  26278. you want to handle any of the standard items in a nonstandard manner,
  26279. you must write your own dlgHook function and point to it with dlgHook.
  26280. Your dlgHook function should have two parameters and return an integer
  26281. value. For example, this is how it would be declared if it were named
  26282. MyDlg:
  26283.  
  26284.        FUNCTION MyDlg (item: INTEGER; theDialog: DialogPtr) : INTEGER;
  26285.  
  26286.     Immediately after calling ModalDialog, SFGetFile calls you dlgHook
  26287. function, passing it the item number returned by ModalDialog and a
  26288. pointer to the dialog record describing you dialog box. Using these
  26289. two parameters, your dlgHook function should determine how to handle
  26290. the event. There are predefined constants for the item numbers of
  26291. standard enabled items, as follows:
  26292.  
  26293.     CONST getOpen    = 1;   {Open button}
  26294.           getCancel  = 3;   {Cancel button}
  26295.           getEject   = 5;   {Eject button}
  26296.           getDrive   = 6;   {Drive button}
  26297.           getNmList  = 7;   {userItem for file name list}
  26298.           getScroll  = 8;   {userItem for scroll bar}
  26299.  
  26300.     ModalDialog also returns "fake" item numbers in the following
  26301. situations, which are detected by its filterProc function:
  26302.  
  26303.    • When a disk-inserted event occurs, it returns 100.
  26304.  
  26305.    • When a key-down event occurs, it returns 1000 plus the ASCII code
  26306.      of the character.
  26307.  
  26308.     After handling the event (or, perhaps, after ignoring it) your
  26309. dlgHook function must return an item number to SFGetFile. If the item
  26310. number is one of those listed above, SFGetFile responds in the standard
  26311. way; otherwise, it does nothing.
  26312.  
  26313. æKY SFPGetFile
  26314. æFp Packages.p
  26315. æT PROCEDURE
  26316. æTN $A9EA
  26317. æD PROCEDURE SFPGetFile(where: Point;prompt: Str255;fileFilter: ProcPtr;
  26318.     numTypes: INTEGER;typeList: SFTypeList;dlgHook: ProcPtr;VAR reply: SFReply;
  26319.     dlgID: INTEGER;filterProc: ProcPtr);
  26320. æDT SFPGetFile(where,prompt,fileFilter,numTypes,typeList,dlgHook,reply,dlgID,
  26321.     filterProc);
  26322. æRT 47, 80
  26323. æRI SFPGetFile procedure I-526
  26324. æC     SFPGetFile is an alternative to SFGetFile for advanced programmers
  26325. who want to use a nonstandard dialog box. It's the same as  SFGetFile
  26326. except for the two additional parameters dlgID and filterProc.
  26327.  
  26328.     DlgID is the resource ID of the dialog template to be used instead
  26329. of the standard one (so you can use whatever ID you wish rather than the
  26330. same one as the standard).
  26331.  
  26332.     The filterProc parameter determines how ModalDialog will filter
  26333. events when called by SFPGetFile. If filterProc is NIL, ModalDialog
  26334. does the standard filtering that it does when called by SFGetFile;
  26335. otherwise, filterProc should point to a function for ModalDialog to
  26336. execute after doing the standard filtering. Note, however, that the
  26337. standard filtering will detect key-down events only if the dialog
  26338. template ID is the standard one.
  26339. æRT 47
  26340. æRI SFPPutFile procedure I-523
  26341.  
  26342. æKY SFPutFile
  26343. æFp Packages.p
  26344. æT PROCEDURE
  26345. æD PROCEDURE SFPutFile(where: Point;prompt: Str255;origName: Str255;dlgHook: ProcPtr;
  26346.     VAR reply: SFReply);
  26347. æDT SFPutFile(where,prompt,origName,dlgHook,reply);
  26348. æMM 
  26349. æRT 47, 80, 107, 226
  26350. æRI SFPutFile procedure I-519, P-125, 128, 162, 181
  26351. æC     SFPutFile displays a dialog box allowing the user to specify a file
  26352. to which data will be written (as during a Save or Save As command). It
  26353. then repeatedly gets and handles events until the user either confirms
  26354. the command after entering an appropriate file name or aborts the
  26355. command by clicking Cancel in the dialog. It reports the user's reply
  26356. by filling the fields of the reply record specified by the reply
  26357. parameter, as described above; the fType field of this record isn't
  26358. used.
  26359.  
  26360.     The general appearance of the standard SFPutFile dialog box is shown
  26361. in Figure S-2. The where parameter specifies the location of the top
  26362. left corner of the dialog box in global coordinates. The prompt
  26363. parameter is a line of text to be displayed as a statText item in the
  26364. dialog box, where shown in Figure S-2. The origName parameter contains
  26365. text that appears as an enabled, selected editText item; for the
  26366. standard document-saving commands, it should be the current name of the
  26367. document, or the empty string (to display an insertion point) if the
  26368. document hasn't been named yet.
  26369.  
  26370.     If you want to use the standard SFPutFile dialog box, pass NIL for
  26371. dlgHook; otherwise, see the information for advanced programmers below.
  26372.  
  26373.     SFPutFile  repeatedly calls the Dialog Manager procedure
  26374. ModalDialog. When an event involving an enabled dialog item occurs,
  26375. ModalDialog handles the event and returns the item number, and
  26376. SFPutFile responds as follows:
  26377.  
  26378.    • If the Eject or Drive button is clicked, or a disk is inserted,
  26379.      SFPutFile responds as described above under "About the Standard
  26380.      File Package".
  26381.  
  26382.    • Text entered into the editText item is stored in the fName field
  26383.      of the reply record. (SFPutFile keeps track of whether there's
  26384.      currently any text in the item, and makes the Save button inactive
  26385.      if not.)
  26386.  
  26387.    • If the Save button is clicked, SFPutFile determines whether the
  26388.      file name in the fName field of the reply record is appropriate.
  26389.      If so, it returns control to the application with the first field
  26390.      of the reply record set to TRUE; otherwise, it responds
  26391.      accordingly, as described below.
  26392.  
  26393.    • If the Cancel button in the dialog is clicked, SFPutFile returns
  26394.      control to the application with the first field of the reply
  26395.      record set to FALSE.
  26396.  
  26397. Note:  
  26398.  
  26399.     Notice that disk insertion is one of the user actions
  26400.     listed above, even though ModalDialog normally ignores
  26401.     disk-inserted events. The reason this works is that
  26402.     SFPutFile calls ModalDialog with a filterProc function
  26403.     that checks for a disk-inserted event and returns a
  26404.     "fake", very large item number if one occurs; SFPutFile
  26405.     recognizes this item number as an indication that a disk
  26406.     was inserted.
  26407.  
  26408.     The situations that may cause an entered name to be inappropriate,
  26409. and SFPutFile's response to each, are as follows:
  26410.  
  26411.      • If a file with the specified name already exists on the disk and
  26412.        is different from what was passed in the origName parameter, the
  26413.        alert in Figure S-3 is displayed. If the user clicks Yes, the
  26414.        file name is appropriate.
  26415.  
  26416.      • If the disk to which the file should be written is locked, the
  26417.        alert in Figure S-4 is displayed. If a system error occurs, a
  26418.        similar alert is displayed, with a corresponding message
  26419.        explaining the problem.
  26420.  
  26421. Note:  
  26422.  
  26423.     The user may specify a disk name (preceding the file name
  26424.     and separated from it by a colon). If the disk isn't
  26425.     currently in a drive, an alert similar to the one in
  26426.     Figure S-4 is displayed. The ability to specify a disk
  26427.     name is supported for historical reasons only; users
  26428.     should not be encouraged to do it.
  26429.  
  26430.     After the user clicks No or Cancel in response to one of these
  26431. alerts, SFPutFile dismisses the alert box and continues handling events
  26432. (so a different name may be entered).
  26433.  
  26434. Advanced programmers:  You can create your own dialog box rather than
  26435. use the standard SFPutFile dialog. To do this, you must provide your
  26436. own dialog template and store it in your application's resource file
  26437. with the same resource ID that the standard template has in the system
  26438. resource file:
  26439.  
  26440.         CONST putDlgID = -3999;   {SFPutFile dialog template ID}
  26441.  
  26442. Note:  
  26443.  
  26444.     The SFPPutFile procedure, described below lets you use
  26445.     any resource ID for your nonstandard dialog box.
  26446.  
  26447.     Your dialog template must specify that the dialog window be
  26448. invisible, and your dialog must contain all the standard items, as
  26449. listed below. The appearance and location of these items in your dialog
  26450. may be different. You can make an item "invisible" by giving it a
  26451. display rectangle that's off the screen. The display rectangle for each
  26452. item in the standard dialog box is given below. The rectangle for the
  26453. standard dialog box itself is (0,0,304,104).
  26454.  
  26455.  
  26456.    Item Number  Item                     Standard display rectangle
  26457.     1       Save button                  (12,74,82,92)
  26458.     2       Cancel button                (114,74,184,92)
  26459.     3       Prompt string (statText)     (12,12,184,28)
  26460.     4       UserItem for disk name       (209,16,295,34)
  26461.     5       Eject button                 (217,43,287,61)
  26462.     6       Drive button                 (217,74,287,92)
  26463.     7       EditText item for file name  (14,34,182,50)
  26464.     8       UserItem for gray line       (200,16,201,88)
  26465.  
  26466.  
  26467. Note:  
  26468.  
  26469.     Remember that the display rectangle for any "invisible"
  26470.     item must be at least about 20 pixels wide.
  26471.  
  26472.     If your dialog has additional items beyond the standard ones, or if
  26473. you want to handle any of the standard items in a nonstandard manner,
  26474. you must write your own dlgHook function and point to it with dlgHook.
  26475. Your dlgHook function should have two parameters and return an integer
  26476. value. For example, this is how it would be declared if it were named
  26477. MyDlg:
  26478.  
  26479.        FUNCTION MyDlg (item: INTEGER; theDialog: DialogPtr) : INTEGER;
  26480.  
  26481.     Immediately after calling ModalDialog, SFPutFile calls your dlgHook
  26482. function, passing it the item number returned by ModalDialog and a
  26483. pointer to the dialog record describing your dialog box. Using these
  26484. two parameters, your dlgHook function should determine how to handle
  26485. the event. There are predefined constants for the item numbers of
  26486. standard enabled items, as follows:
  26487.  
  26488.       CONST putSave   = 1;   {Saver button}
  26489.             putCancel = 2;   {Cancel button}
  26490.             putEject  = 5;   {Eject button}
  26491.             putDrive  = 6;   {Drive button}
  26492.             putName   = 7;   {editText item for file name}
  26493.  
  26494.     ModalDialog also returns the "fake" item number 100 when a disk-
  26495. inserted event occurs, as detected by its filterProc function.
  26496.  
  26497.     After handling the event (or, perhaps, after ignoring it) the
  26498. dlgHook function must return an item number to SFPutFile. If the item
  26499. number is one of those listed above, SFPutFile responds in the standard
  26500. way; otherwise, it does nothing.
  26501.  
  26502. Note:  
  26503.  
  26504.     For advanced programmers who want to change the
  26505.     appearance of the alerts displayed when an inappropriate
  26506.     file name is entered, the resource IDs of those alerts in
  26507.     the system resource file are listed below.
  26508.  
  26509.  
  26510.        Alert                   Resource ID
  26511.        
  26512.        Existing file             -3996
  26513.        Locked disk               -3997
  26514.        System error              -3995
  26515.        Disk not found            -3994
  26516. æMM 
  26517. æRT 47, 80, 107, 226
  26518. æRI SFPutFile procedure I-519, P-125, 128, 162, 181
  26519.  
  26520. æKY SFReply
  26521. æFp Packages.p
  26522. æT RECORD
  26523. æC SFReply = RECORD
  26524.    good: BOOLEAN;
  26525.    copy: BOOLEAN;
  26526.    fType: OSType;
  26527.    vRefNum: INTEGER;
  26528.    version: INTEGER;
  26529.    fName: Str63;
  26530.    END;
  26531.  
  26532. æKY SFTypeList
  26533. æFp Packages.p
  26534. æT TYPE
  26535. æC SFTypeList = ARRAY [0..3] OF OSType;
  26536.  
  26537. æKY StringToNum
  26538. æFp Packages.p
  26539. æT PROCEDURE
  26540. æTN $A9EE
  26541. æD PROCEDURE StringToNum(theString: Str255;VAR theNum: LONGINT);
  26542. æDT StringToNum(theString,theNum);
  26543. æMM   
  26544. æRI StringToNum procedure I-490
  26545. æC _____________________________________________________________________________________
  26546.  
  26547. Trap macro     _StringToNum
  26548.  
  26549. On entry       A0:  pointer to theString (length byte followed
  26550.                     by characters)
  26551.  
  26552. On exit        DO:  theNum (long integer)
  26553.  
  26554. _____________________________________________________________________________________
  26555.  
  26556.  
  26557. Given a string representing a decimal integer, StringToNum converts
  26558. it to the corresponding integer and returns the result in theNum. The
  26559. string may begin with a plus or minus sign. For example:
  26560.  
  26561.       theString          theNum
  26562.         '12'               12
  26563.        '-23'              -23
  26564.         '-0'                0
  26565.        '055'               55
  26566.  
  26567.     The magnitude of the integer is converted modulo 2^32, and the
  26568. 32-bit result is negated if the string begins with a minus sign; integer
  26569. overflow occurs if the magnitude is greater than 2^31-1. (Negation is
  26570. done by taking the two's complement--reversing the state of each bit
  26571. and then adding 1.)  For example:
  26572.  
  26573.         theString                                   theNum
  26574.        '2147483648'  (magnitude is 2^31)          -2147483648
  26575.       '-2147483648'                               -2147483648
  26576.        '4294967295'  (magnitude is 2^31)              -1
  26577.       '-4294967295'                                    1
  26578.  
  26579.     StringToNum doesn't actually check whether the characters in the
  26580. string are between '0' and '9'; instead, since the ASCII codes for '0'
  26581. through '9' are $30 through $39, it just masks off the last four bits
  26582. and uses them as a digit. For example, '2:' is converted to the number
  26583. 30 because the ASCI code for ':' is $3A. Leading spaces before the
  26584. first digit are treated as zeroes, since the ASCII code for a space is
  26585. $20. Given that the ASCII codes for 'C', 'A', and 'T' are $43, $41, and
  26586. $54, respectively, consider the following examples:
  26587.  
  26588.  
  26589.       theString              theNum
  26590.         'CAT'                  314
  26591.        '+CAT'                  314
  26592.        '-CAT'                 -314
  26593. æMM   
  26594. æRI StringToNum procedure I-490
  26595.  
  26596. æKY supDay
  26597. æFp Packages.p
  26598. æC supDay = 1; {suppress day of month}
  26599.  
  26600. æKY supMonth
  26601. æFp Packages.p
  26602. æC supMonth = 4; {suppress month}
  26603.  
  26604. æKY supWeek
  26605. æFp Packages.p
  26606. æC supWeek = 2; {suppress day of week}
  26607.  
  26608. æKY supYear
  26609. æFp Packages.p
  26610. æC supYear = 8; {suppress year}
  26611.  
  26612. æKY verArabia
  26613. æFp Packages.p
  26614. æC verArabia = 16;
  26615.  
  26616. æKY verAustralia
  26617. æFp Packages.p
  26618. æC verAustralia = 15;
  26619.  
  26620. æKY verBelgiumLux
  26621. æFp Packages.p
  26622. æC verBelgiumLux = 6;
  26623.  
  26624. æKY verBritain
  26625. æFp Packages.p
  26626. æC verBritain = 2;
  26627.  
  26628. æKY verChina
  26629. æFp Packages.p
  26630. æC verChina = 52;
  26631.  
  26632. æKY verCyprus
  26633. æFp Packages.p
  26634. æC verCyprus = 23;
  26635.  
  26636. æKY verDenmark
  26637. æFp Packages.p
  26638. æC verDenmark = 9;
  26639.  
  26640. æKY verFinland
  26641. æFp Packages.p
  26642. æC verFinland = 17;
  26643.  
  26644. æKY verFrance
  26645. æFp Packages.p
  26646. æC verFrance = 1;
  26647.  
  26648. æKY verFrCanada
  26649. æFp Packages.p
  26650. æC verFrCanada = 11;
  26651.  
  26652. æKY verFrSwiss
  26653. æFp Packages.p
  26654. æC verFrSwiss = 18;
  26655.  
  26656. æKY verGermany
  26657. æFp Packages.p
  26658. æC verGermany = 3;
  26659.  
  26660. æKY verGreece
  26661. æFp Packages.p
  26662. æC verGreece = 20;
  26663.  
  26664. æKY verGrSwiss
  26665. æFp Packages.p
  26666. æC verGrSwiss = 19;
  26667.  
  26668. æKY verIceland
  26669. æFp Packages.p
  26670. æC verIceland = 21;
  26671.  
  26672. æKY verIreland
  26673. æFp Packages.p
  26674. æC verIreland = 50;
  26675.  
  26676. æKY verIsrael
  26677. æFp Packages.p
  26678. æC verIsrael = 13;
  26679.  
  26680. æKY verItaly
  26681. æFp Packages.p
  26682. æC verItaly = 4;
  26683.  
  26684. æKY verJapan
  26685. æFp Packages.p
  26686. æC verJapan = 14;
  26687.  
  26688. æKY verKorea
  26689. æFp Packages.p
  26690. æC verKorea = 51;
  26691.  
  26692. æKY verMalta
  26693. æFp Packages.p
  26694. æC verMalta = 22;
  26695.  
  26696. æKY verNetherlands
  26697. æFp Packages.p
  26698. æC verNetherlands = 5;
  26699.  
  26700. æKY verNorway
  26701. æFp Packages.p
  26702. æC verNorway = 12;
  26703.  
  26704. æKY verPortugal
  26705. æFp Packages.p
  26706. æC verPortugal = 10;
  26707.  
  26708. æKY verSpain
  26709. æFp Packages.p
  26710. æC verSpain = 8;
  26711.  
  26712. æKY verSweden
  26713. æFp Packages.p
  26714. æC verSweden = 7;
  26715.  
  26716. æKY verTaiwan
  26717. æFp Packages.p
  26718. æC verTaiwan = 53;
  26719.  
  26720. æKY verThailand
  26721. æFp Packages.p
  26722. æC verThailand = 54;
  26723.  
  26724. æKY verTurkey
  26725. æFp Packages.p
  26726. æC verTurkey = 24;
  26727.  
  26728. æKY verUS
  26729. æFp Packages.p
  26730. æC verUS = 0;
  26731.  
  26732. æKY verYugoslavia
  26733. æFp Packages.p
  26734. æC verYugoslavia = 25;
  26735.  
  26736. æKY ydm
  26737. æFp Packages.p
  26738. æC ydm = 5;
  26739.  
  26740. æKY ymd
  26741. æFp Packages.p
  26742. æC ymd = 2;
  26743.  
  26744. æKY zeroCycle
  26745. æFp Packages.p
  26746. æC zeroCycle = 1; {0:00 AM/PM format}
  26747.  
  26748.  
  26749. æKY Palettes.p
  26750. æKL ActivatePalette
  26751. AnimateEntry
  26752. AnimatePalette
  26753. CopyPalette
  26754. CTab2Palette
  26755. DisposePalette
  26756. GetEntryColor
  26757. GetEntryUsage
  26758. GetNewPalette
  26759. GetPalette
  26760. InitPalettes
  26761. NewPalette
  26762. NSetPalette
  26763. Palette2CTab
  26764. PmBackColor
  26765. PmForeColor
  26766. SetEntryColor
  26767. SetEntryUsage
  26768. SetPalette
  26769.  
  26770. ColorInfo
  26771. Palette
  26772. PaletteHandle
  26773. PalettePtr
  26774. pmAllUpdates
  26775. pmAnimated
  26776. PmBackColor
  26777. PmBackColor
  26778. pmBkUpdates
  26779. pmCourteous
  26780. pmDithered
  26781. pmExplicit
  26782. pmFgUpdates
  26783. PmForeColor
  26784. PmForeColor
  26785. pmNoUpdates
  26786. pmTolerant
  26787. SetEntryColor
  26788.  
  26789. æKY Palette,PalettePtr,PaletteHandle
  26790. æFp Palettes.p
  26791. æT TYPE
  26792. æC PalettePtr = ^Palette;
  26793. PaletteHandle = ^PalettePtr;
  26794. Palette = RECORD
  26795.    pmEntries: INTEGER;                     {entries in pmTable}
  26796.    pmDataFields: ARRAY [0..6] OF INTEGER;  {private fields}
  26797.    pmInfo: ARRAY [0..0] OF ColorInfo;
  26798.    END;
  26799.  
  26800. TYPE
  26801.    PaletteHandle = ^PalettePtr;
  26802.    PalettePtr    = ^Palette;
  26803.    Palette       = RECORD
  26804.                      pmEntries:     integer;                 {entries in pmInfo}
  26805.                      pmDataFields:  array [0..6] of integer; {private fields}
  26806.                      pmInfo:        array [0..0] of ColorInfo;
  26807.                    END;
  26808.  
  26809. Field descriptions
  26810.  
  26811. pmEntries     The pmEntries field contains the number of entries in the pmTable.
  26812. pmDataFields  The pmDataFields field contains an array of integers that are
  26813.               used internally by the Palette Manager.
  26814. pmInfo        The pmInfo field contains an array of ColorInfo records.
  26815.  
  26816. æKY ActivatePalette
  26817. æFp Palettes.p
  26818. æT PROCEDURE
  26819. æTN $AA94
  26820. æD PROCEDURE ActivatePalette(srcWindow: WindowPtr);
  26821. æDT ActivatePalette(srcWindow);
  26822. æMM   
  26823. æRI ActivatePalette procedure  V-162
  26824. æC 
  26825. ActivatePalette is the routine called by the Window Manager when your window’s status
  26826. changes:  for example, when it opens, closes, moves, or becomes frontmost.  You
  26827. should call ActivatePalette after making changes to a palette with the utility routines
  26828. described below.  Such changes do not take effect until the next call to ActivatePalette,
  26829. thereby allowing you to make a series of palette changes without any immediate change
  26830. in the color environment.
  26831.  
  26832. If srcWindow is frontmost, ActivatePalette examines the information stored in the
  26833. palette associated with srcWindow and attempts to provide the color environment
  26834. described therein.  It determines a list of devices on which to render the palette by
  26835. intersecting the port rect of the srcWindow with each device.  If the intersection is
  26836. not empty, and if the device has a Color Look-Up Table (CLUT), then ActivatePalette
  26837. checks to see if the color environment is sufficient.  If a change is required,
  26838. ActivatePalette calls the Color Manager to reserve or modify the device’s color
  26839. entries as required.  It then generates update events for all affected windows which
  26840. desire color updates.
  26841.  
  26842. æKY AnimateEntry
  26843. æFp Palettes.p
  26844. æT PROCEDURE
  26845. æTN $AA99
  26846. æD PROCEDURE AnimateEntry(dstWindow: WindowPtr;dstEntry: INTEGER;srcRGB: RGBColor);
  26847. æDT AnimateEntry(dstWindow,dstEntry,srcRGB);
  26848. æRI AnimateEntry procedure  V-164
  26849. æC 
  26850. AnimateEntry changes the RGB value of dstEntry in the palette associated with dstWindow
  26851. to the color specified by srcRGB.  Each device for which an index has been reserved
  26852. is immediately modified to contain the new value.  This is not considered to be a
  26853. change to the device’s color environment since no other windows should be using the
  26854. animated entry.  If the palette entry is not an animating color, or if the associated
  26855. indexes are no longer reserved, no animation is performed.
  26856.  
  26857. If you have blocked color updates in a window, by using SetPalette with CUpdates set
  26858. to FALSE, you may observe undesired animation.  This will occur when ActivatePalette
  26859. reserves device indexes for animation which are already used in the window.  Redrawing
  26860. the window, which normally occurs as the result of a color update event, will remove
  26861. any animating colors which do not belong to it.
  26862.  
  26863. æKY AnimatePalette
  26864. æFp Palettes.p
  26865. æT PROCEDURE
  26866. æTN $AA9A
  26867. æD PROCEDURE AnimatePalette(dstWindow: WindowPtr;srcCTab: CTabHandle;srcIndex: INTEGER;
  26868.     dstEntry: INTEGER;dstLength: INTEGER);
  26869. æDT AnimatePalette(dstWindow,srcCTab,srcIndex,dstEntry,dstLength);
  26870. æRI AnimatePalette procedure  V-164
  26871. æC 
  26872. AnimatePalette performs a function similar to AnimateEntry, but it acts upon a range
  26873. of palette entries.  Beginning at srcIndex (which has a minimum value of 0), the next
  26874. dstLength entries are copied from srcCTab to dstWindow’s palette, beginning at dstEntry.
  26875. If srcCTab is not sufficiently large to accommodate the request, as many entries are
  26876. modified as possible and the remaining entries are left unchanged.
  26877.  
  26878. æKY ColorInfo
  26879. æFp Palettes.p
  26880. æT RECORD
  26881. æC ColorInfo = RECORD
  26882.    ciRGB: RGBColor;                        {true RGB values}
  26883.    ciUsage: INTEGER;                       {color usage}
  26884.    ciTolerance: INTEGER;                   {tolerance value}
  26885.    ciDataFields: ARRAY [0..2] OF INTEGER;  {private fields}
  26886.    END;
  26887.  
  26888. »COLOR PALETTE RECORDS
  26889. _______________________________________________________________________________
  26890.  
  26891. The basic data structure for a color palette is the ColorInfo record. It consists of
  26892. the following:
  26893.  
  26894. TYPE
  26895.  ColorInfo = RECORD
  26896.                ciRGB:        RGBColor;  {absolute RGB values}
  26897.                ciUsage:      INTEGER    {color usage information}
  26898.                ciTolerance:  INTEGER;   {tolerance value}
  26899.                ciFlags:      INTEGER;   {private field}
  26900.                ciPrivate:    LONGINT;   {private field}
  26901.              END;
  26902.  
  26903. Field descriptions
  26904.  
  26905. ciRGB        The ciRGB is the absolute RGB value defined by Color QuickDraw.
  26906. ciUsage      The ciUsage field contains color usage information that
  26907.              determines the properties of a color.
  26908. ciTolerance  The ciTolerance is a value used to determine if a color is close
  26909.              enough to the color chosen; if the tolerance value is exceeded,
  26910.              the preferred color is rendered in the device’s color table for
  26911.              the selected index.
  26912. ciFlags      The ciFlags field is used internally by the Palette Manager.
  26913. ciPrivate    The ciPrivate field is used internally to store information
  26914.              about color allocation: not for use by application.
  26915.  
  26916. The data structure for a color palette is made up of an array of ColorInfo records,
  26917. plus other information relating to the use of the colors within the palette. The
  26918. 'pltt' resource is an image of the Palette data structure.
  26919.  
  26920. Note:  The palette is accessed through the Palette Manager routines only:
  26921.        do not attempt to directly access any of the fields in this data
  26922.        structure.
  26923.  
  26924. æKY CopyPalette
  26925. æFp Palettes.p
  26926. æT PROCEDURE
  26927. æTN $AAA1
  26928. æD PROCEDURE CopyPalette(srcPalette: PaletteHandle;dstPalette: PaletteHandle;
  26929.     srcEntry: INTEGER;dstEntry: INTEGER;dstLength: INTEGER);
  26930. æDT CopyPalette(srcPalette,dstPalette,srcEntry,dstEntry,dstLength);
  26931. æMM 
  26932. æRT 211
  26933.  
  26934.  
  26935. æKY CTab2Palette
  26936. æFp Palettes.p
  26937. æT PROCEDURE
  26938. æTN $AA9F
  26939. æD PROCEDURE CTab2Palette(srcCTab: CTabHandle;dstPalette: PaletteHandle;
  26940.     srcUsage: INTEGER;srcTolerance: INTEGER);
  26941. æDT CTab2Palette(srcCTab,dstPalette,srcUsage,srcTolerance);
  26942. æMM   
  26943. æRI CTab2Palette procedure  V-165
  26944. æC 
  26945. CTab2Palette is a convenience procedure which copies the fields from an existing
  26946. ColorTable record into an existing Palette record.  If the records are not the same
  26947. size then the Palette record is resized to match the number of entries in the ColorTable
  26948. record.  If dstPalette has any entries allocated for animation on any display device,
  26949. these entries are relinquished prior to copying the new colors.  If you wish to
  26950. effect color table animation you can change the colors in a palette, and on corresponding
  26951. devices, with the AnimateEntry and AnimatePalette routines described above.  Changes
  26952. made to a palette by CTab2Palette don’t take effect until the next ActivatePalette is
  26953. performed.  If either the color table handle or the palette handle are NIL, no operation
  26954. is performed.
  26955.  
  26956. æKY DisposePalette
  26957. æFp Palettes.p
  26958. æT PROCEDURE
  26959. æTN $AA93
  26960. æD PROCEDURE DisposePalette(srcPalette: PaletteHandle);
  26961. æDT DisposePalette(srcPalette);
  26962. æMM   
  26963. æRI DisposePalette procedure  V-162
  26964. æC 
  26965. DisposePalette disposes of a Palette object.  If the palette has any entries allocated
  26966. for animation on any display device, these entries are relinquished prior to deallocation
  26967. of the object.
  26968.  
  26969. æKY GetEntryColor
  26970. æFp Palettes.p
  26971. æT PROCEDURE
  26972. æTN $AA9B
  26973. æD PROCEDURE GetEntryColor(srcPalette: PaletteHandle;srcEntry: INTEGER;
  26974.     VAR dstRGB: RGBColor);
  26975. æDT GetEntryColor(srcPalette,srcEntry,dstRGB);
  26976. æRI GetEntryColor procedure  V-164
  26977. æC 
  26978. GetEntryColor allows your application to access the color of a palette entry.  The
  26979. color may be modified by using the SetEntryColor routine described below.
  26980.  
  26981. æKY GetEntryUsage
  26982. æFp Palettes.p
  26983. æT PROCEDURE
  26984. æTN $AA9D
  26985. æD PROCEDURE GetEntryUsage(srcPalette: PaletteHandle;srcEntry: INTEGER;
  26986.     VAR dstUsage: INTEGER;VAR dstTolerance: INTEGER);
  26987. æDT GetEntryUsage(srcPalette,srcEntry,dstUsage,dstTolerance);
  26988. æRI GetEntryUsage procedure  V-165
  26989. æC 
  26990. GetEntryUsage allows your application to access the usage fields of a palette entry,
  26991. namely ciUsage and ciTolerance.  These fields may be modified by using the SetEntryUsage
  26992. routine described below.
  26993.  
  26994. æKY GetNewPalette
  26995. æFp Palettes.p
  26996. æT FUNCTION
  26997. æTN $AA92
  26998. æD FUNCTION GetNewPalette(PaletteID: INTEGER): PaletteHandle;
  26999. æDT myVariable := GetNewPalette(PaletteID);
  27000. æMM   
  27001. æRI GetNewPalette function  V-162
  27002. æC 
  27003. GetNewPalette fetches a Palette object from the Resource Manager and initializes it. 
  27004. If you open a new color window with GetNewCWindow, this routine is called automatically
  27005. with paletteID equal to the window’s resource ID.  A palette resource is identified
  27006. by type 'pltt'.  A paletteID of 0 is reserved for the system palette resource which
  27007. is used as the default palette for noncolor windows and color windows without assigned
  27008. palettes.
  27009.  
  27010. æKY GetPalette
  27011. æFp Palettes.p
  27012. æT FUNCTION
  27013. æTN $AA96
  27014. æD FUNCTION GetPalette(srcWindow: WindowPtr): PaletteHandle;
  27015. æDT myVariable := GetPalette(srcWindow);
  27016. æRT 211
  27017. æRI GetPalette function  V-163
  27018. æC 
  27019. GetPalette returns a handle to the palette associated with srcWindow.  If no palette
  27020. is associated with srcWindow, or if srcWindow is not a color window, GetPalette
  27021. returns NIL.
  27022.  
  27023. æKY InitPalettes
  27024. æFp Palettes.p
  27025. æT PROCEDURE
  27026. æTN $AA90
  27027. æD PROCEDURE InitPalettes;
  27028. æDT InitPalettes;
  27029. æMM 
  27030. æRT 211
  27031. æRI InitPalettes procedure  V-161
  27032. æC 
  27033. InitPalettes initializes the Palette Manager.  It searches for devices which support
  27034. a Color Look-Up Table (CLUT) and initializes an internal data structure for each one.
  27035. This call is made by InitWindows and should not have to be made by your application.
  27036.  
  27037. æKY NewPalette
  27038. æFp Palettes.p
  27039. æT FUNCTION
  27040. æTN $AA91
  27041. æD FUNCTION NewPalette(entries: INTEGER;srcColors: CTabHandle;srcUsage: INTEGER;
  27042.     srcTolerance: INTEGER): PaletteHandle;
  27043. æDT myVariable := NewPalette(entries,srcColors,srcUsage,srcTolerance);
  27044. æMM   
  27045. æRI NewPalette function  V-161
  27046. æC 
  27047. NewPalette allocates a new Palette object which contains a table of colors with
  27048. enough room for “entries” colors.  It fills the table with as many RGB values from
  27049. srcColors as it has or as it can fit.  It sets the usage field of each color to
  27050. srcUsage and the tolerance value of each color to srcTolerance.  If no color table is
  27051. provided (srcColors = NIL) then all colors in the palette are set to black (red =
  27052. $0000, green = $0000, blue = $0000 ).
  27053.  
  27054. æKY NSetPalette
  27055. æFp Palettes.p
  27056. æT PROCEDURE
  27057. æTN $AA95
  27058. æD PROCEDURE NSetPalette(dstWindow: WindowPtr;srcPalette: PaletteHandle;
  27059.     nCUpdates: INTEGER);
  27060. æDT NSetPalette(dstWindow,srcPalette,nCUpdates);
  27061. æRT 211
  27062.  
  27063.  
  27064. æKY Palette2CTab
  27065. æFp Palettes.p
  27066. æT PROCEDURE
  27067. æTN $AAA0
  27068. æD PROCEDURE Palette2CTab(srcPalette: PaletteHandle;dstCTab: CTabHandle);
  27069. æDT Palette2CTab(srcPalette,dstCTab);
  27070. æMM   
  27071. æRI Palette2CTab procedure  V-166
  27072. æC 
  27073. Palette2CTab is a convenience procedure which copies all of the colors from an existing
  27074. Palette record into an existing ColorTable record.  If the records are not the same
  27075. size then the ColorTable record is resized to match the number of entries in the
  27076. Palette record.  If either the palette handle or the color table handle are NIL, no
  27077. operation is performed.
  27078.  
  27079. æKY pmAllUpdates
  27080. æFp Palettes.p
  27081. æC pmAllUpdates = $E000; {all updates}
  27082.  
  27083. æKY PmBackColor
  27084. æFp Palettes.p
  27085. æT PROCEDURE
  27086. æTN $AA98
  27087. æD PROCEDURE PmBackColor(dstEntry: INTEGER);
  27088. æDT PmBackColor(dstEntry);
  27089. æMM 
  27090. æRT 211
  27091. æRI PmBackColor procedure  V-163
  27092. æC 
  27093. These routines enable applications to specify foreground and background drawing
  27094. colors with the assistance of the Palette Manager.  Substitute these for Color Quickdraw’s
  27095. RGBForeColor and RGBBackColor routines when you wish to use a color from a palette. 
  27096. You may still use RGBForeColor and RGBBackColor in the normal way whenever you wish
  27097. to specify drawing colors, for example when you wish to use a color which is not
  27098. contained in your palette.
  27099.  
  27100. PmBackColor sets the RGB and index backcolor fields of the current cGrafPort according
  27101. to the palette entry of the current cGrafPort (window) corresponding to dstEntry. 
  27102. For courteous and tolerant entries, this call performs an RGBBackColor using the RGB
  27103. color of the palette entry. For animating colors it will select the recorded device
  27104. index previously reserved for animation (if still present) and install it in the
  27105. cGrafPort.  The RGB backcolor field is set to the value from the palette entry.  For
  27106. explicit colors PmBackColor places
  27107. (dstEntry modulo (MaxIndex+1)) into the cGrafPort, where MaxIndex is the largest
  27108. index available in a device’s color table.  When multiple devices are present with
  27109. different depths, MaxIndex varies appropriately for each device.
  27110.  
  27111. æKY pmBkUpdates
  27112. æFp Palettes.p
  27113. æC pmBkUpdates = $A000; {background updates only}
  27114.  
  27115. æKY pmCourteous,pmDithered,pmTolerant,pmAnimated,pmExplicit
  27116. æFp Palettes.p
  27117. æC 
  27118. »Color Usage
  27119.  
  27120. The Palette Manager uses one of four methods for selecting colors:
  27121.  
  27122.   •  Courteous colors have no special properties. For such colors, the Palette
  27123.      Manager relies upon Color QuickDraw to select appropriate pixel values.
  27124.      Colors with specified usages that can’t be satisfied by the Palette
  27125.      Manager will default to courteous colors. This occurs, for example, when
  27126.      drawing to a device with no color look-up table, such as a direct or fixed
  27127.      device. Courteous colors don’t change the color environment in any way.
  27128.   •  Tolerant colors cause a change in the color environment unless the fit to
  27129.      the best matching available color falls within a separately specified
  27130.      tolerance value.
  27131.   •  Animating colors are reserved by a palette and are unavailable to (and
  27132.      can’t be matched by) any other request for color.
  27133.   •  Explicit colors always generate the corresponding entry in the device’s
  27134.      color table.
  27135.  
  27136. These color types are specified when using Palette Manager routines by using the
  27137. following constants:
  27138.  
  27139. CONST { Usage constants }
  27140.  
  27141.       pmCourteous = $0000;
  27142.       pmDithered  = $0001; {reserved for future use}
  27143.       pmTolerant  = $0002;
  27144.       pmAnimated  = $0004;
  27145.       pmExplicit  = $0008;
  27146.  
  27147. When you specify colors for a palette within a 'pltt' resource, you will usually
  27148. assign the same usage value to each color in the palette. However, if for some reason
  27149. a particular color must be used differently than the other colors in the palette, it
  27150. can be assigned a different usage value, either within the resource file, or within
  27151. the application through use of the SetEntryUsage routine.
  27152.  
  27153. The sections that follow provide more information on these color types.
  27154.  
  27155. »Courteous Colors
  27156.  
  27157. Courteous colors are provided for two reasons.  First, they are a convenient placeholder.
  27158.  If your application uses only a small number of colors you can place each of them in
  27159. a palette, ordered according to your preference.  Suppose you have a palette resource
  27160. which consists of a set of eight colors, namely white, black, red, orange, yellow,
  27161. green, blue, and violet, in that order, each with a usage specified as courteous. 
  27162. Assuming further that the palette resource ID number matched that of a color window
  27163. (myColorWindow) you opened earlier, the following calls will paint a rectangle (myRect)
  27164. in yellow (palette entry 4, where white is 0):
  27165.  
  27166.   SetPort (myColorWindow);
  27167.   PmForeColor (4);
  27168.   PaintRect (myRect);
  27169.  
  27170. This is exactly analogous to the following sequence of calls made using Color Quickdraw
  27171. routines, where yellowRGB is of type ColorSpec:
  27172.  
  27173.   with yellowRGB do begin {done once during your initialization}
  27174.        red := $FFFF;
  27175.        green := $FFFF;
  27176.        blue := $0000
  27177.        end;
  27178.  
  27179.   SetPort (myColorWindow);
  27180.   RGBForeColor (yellowRGB);
  27181.   PaintRect (myRect);
  27182.  
  27183. The second reason for providing courteous colors is not immediately apparent.  It
  27184. involves how colors are selected for palettes which use animation.  The Palette
  27185. Manager has access to all palettes used by all windows throughout the system.  When
  27186. deciding which of a device’s colors to allocate for animation, it checks each window
  27187. currently drawn on that device to see which colors the windows are using.  It then
  27188. chooses the color which is least used and reserves that for animation.  In the first
  27189. example shown above, the Palette Manager would try to avoid the eight colors used in
  27190. your palette, even though they are just courteous colors.  In the second example it
  27191. would have no knowledge of your colors and might steal them unnecessarily, and when
  27192. your window is redrawn the selected colors might not be as close to the desired
  27193. colors as they previously were.  If you intend to use only a limited number of colors
  27194. it is therefore best to place them in the window’s palette so the Palette Manager
  27195. will know about them.
  27196.  
  27197. »Tolerant Colors
  27198.  
  27199. Tolerant colors allow you to change the current color environment according to your
  27200. needs.  When your window becomes the frontmost window on a device its palette and the
  27201. colors contained therein are given preference.  Each tolerant color is compared to
  27202. the best unique match available in the current color environment (for each device on
  27203. which the window is drawn).  When the difference between your color and the best
  27204. available match is greater than the tolerance you have specified the Palette Manager
  27205. will modify the color environment to provide an exact match to your color.
  27206.  
  27207. The tolerance value associated with each palette entry is compared to a measure of
  27208. the difference between two RGBColor values.  This difference is an approximation of
  27209. the distance between the two points as measured in a Cartesian coordinate system
  27210. where the axes are the unsigned red, green, and blue values.  The distance formula
  27211. used is shown below:
  27212.  
  27213.   Δ RGB = maximum of (abs(Red1–Red2), abs(Green1–Green2), abs(Blue1–Blue2))
  27214.  
  27215. A value of $5000 is generally sufficient to allow matching without updates in reasonably
  27216. well-balanced color environments. A tolerance value of $0000 means that only an exact
  27217. match is acceptable. Any value of $0xxx, other than $0000, is reserved, and should
  27218. not be used in applications.
  27219.  
  27220. If your palette requires more colors than are currently available the Palette Manager
  27221. will check to see if any other palette has reserved entries for animation.  If so it
  27222. will dereserve them and make them available for your palette.  If you ask for more
  27223. than are available on a device, the Palette Manager cannot honor your request. 
  27224. However, you can still call PmForeColor for such colors; as mentioned earlier, such
  27225. colors default to courteous colors. Color QuickDraw will still select the best color
  27226. available, which of course must match one of the colors elsewhere in your palette
  27227. since the Palette Manager will only run out of colors after it has given your palette
  27228. all that it has.  Two exceptions to this rule are noted below.  See the “Black,
  27229. White, and Palette Customization” section and the “Palette Prioritization” section
  27230. describing the interaction among colors of different usages in a single palette.
  27231.  
  27232. »Animating Colors
  27233.  
  27234. Animating colors allow you to reserve device indexes for color table animation.  Each
  27235. animating color is checked to see if it already has a reserved index for the target
  27236. device.  If it does not, the Palette Manager attempts to find a suitable index.  This
  27237. is done by checking all windows to see what colors they use, and which device indexes
  27238. match those colors.  The least frequently used indexes are then reserved for your
  27239. palette.  The reservation process is analogous to the Color Manager call ReserveEntry.
  27240.  The device index and its corresponding color value is removed from the matching
  27241. scheme used by Color Quickdraw; you cannot draw with it by calling RGBForeColor. 
  27242. However, when you call PmForeColor the Palette Manager will locate the reserved index
  27243. and configure your window’s port to draw with it.  On multiple devices this will
  27244. likely be a different index for each device, but this process will be invisible to
  27245. your application.
  27246.  
  27247. After reserving one or more device indexes for each animating entry it detects, the
  27248. Palette Manager will change the color environment to match the RGB values specified
  27249. in the palette.  To use an animating color you must first draw with it using PmForeColor
  27250. or PmBackColor.  To effect color table animation you can use either AnimateEntry (for
  27251. a single color) or AnimatePalette (for a contiguous set of colors).  These calls are
  27252. described in the section titled
  27253. “Palette Manager Routines”.
  27254.  
  27255. »Explicit Colors
  27256.  
  27257. Explicit colors are provided as a convenience for users who wish to use colors in
  27258. very special ways.  The RGB value in a palette is completely ignored if a color is an
  27259. explicit color.  Explicit colors cause no change in the color environment and are not
  27260. counted for purposes of animation.  Explicit colors always match the corresponding
  27261. device index.  A PmForeColor call with a parameter of 12 will place a value of (12
  27262. modulo (MaxIndex+1)) into the foreground color field of your window’s cGrafPort,
  27263. where MaxIndex is the maximum available index for each device under consideration. 
  27264. When you draw with an explicit color, you get whatever color the device index currently
  27265. contains.
  27266.  
  27267. One interesting use for explicit colors is that it allows you to monitor the color
  27268. environment on a device.  For example, you could draw a grid of 256 explicit colors,
  27269. 16-by-16, in a small window.  The colors shown are exactly those in the device’s
  27270. color table.  If color table animation is taking place simultaneously the corresponding
  27271. colors in the small window will animate as well. If you display such a window on a
  27272. 4-bit device, the first 16 colors will match the 16 colors available in the device
  27273. and each row thereafter will be a copy of the first row.
  27274.  
  27275. However, the main purpose for explicit colors is to provide a convenient indexed
  27276. color interface.  Using the Color Manager, you can establish a known color environment
  27277. using the SetEntries routine on each device of interest.  You can then easily select
  27278. any of these colors for drawing by setting your window’s palette to contain as many
  27279. explicit colors as are in the target device with the greatest number of indexes. 
  27280. PmForeColor will configure the cGrafPort to draw with the index of your choice.
  27281.  
  27282. Warning:  You should not use explicit colors in this fashion if you intend
  27283.           your application to coexist in multi-application environments such
  27284.           as those provided by MultiFinder™ or A/UX™ or when using color desk
  27285.           accessories that depend upon the Palette Manager.  However, for
  27286.           certain types of applications, especially those which are written
  27287.           for a known device environment, explicit colors will tend to make
  27288.           indexed color manipulation much more convenient.
  27289.  
  27290. æKY pmFgUpdates
  27291. æFp Palettes.p
  27292. æC pmFgUpdates = $C000; {foreground updates only}
  27293.  
  27294. æKY PmForeColor
  27295. æFp Palettes.p
  27296. æT PROCEDURE
  27297. æTN $AA97
  27298. æD PROCEDURE PmForeColor(dstEntry: INTEGER);
  27299. æDT PmForeColor(dstEntry);
  27300. æMM 
  27301. æRT 211
  27302. æRI PmForeColor procedure  V-163
  27303. æC 
  27304. These routines enable applications to specify foreground and background drawing
  27305. colors with the assistance of the Palette Manager.  Substitute these for Color Quickdraw’s
  27306. RGBForeColor and RGBBackColor routines when you wish to use a color from a palette. 
  27307. You may still use RGBForeColor and RGBBackColor in the normal way whenever you wish
  27308. to specify drawing colors, for example when you wish to use a color which is not
  27309. contained in your palette.
  27310.  
  27311. PmForeColor sets the RGB and index forecolor fields of the current cGrafPort according
  27312. to the palette entry of the current cGrafPort (window) corresponding to dstEntry. 
  27313. For courteous and tolerant entries, this call performs an RGBForeColor using the RGB
  27314. color of the palette entry.  For animating colors it will select the recorded device
  27315. index previously reserved for animation (if still present) and install it in the
  27316. cGrafPort.  The RGB forecolor field is set to the value from the palette entry.  For
  27317. explicit colors PmForeColor places
  27318. (dstEntry modulo (MaxIndex+1)) into the cGrafPort, where MaxIndex is the largest
  27319. index available in a device’s CLUT.  When multiple devices are present with different
  27320. depths, MaxIndex varies appropriately for each device.
  27321.  
  27322. æKY pmNoUpdates
  27323. æFp Palettes.p
  27324. æC pmNoUpdates = $8000; {no updates}
  27325.  
  27326. æKY SetEntryColor
  27327. æFp Palettes.p
  27328. æT PROCEDURE
  27329. æTN $AA9C
  27330. æD PROCEDURE SetEntryColor(dstPalette: PaletteHandle;dstEntry: INTEGER;
  27331.     srcRGB: RGBColor);
  27332. æDT SetEntryColor(dstPalette,dstEntry,srcRGB);
  27333. æRI SetEntryColor procedure  V-165
  27334. æC 
  27335. SetEntryColor provides a convenient way for your application to modify the color of a
  27336. single palette entry.  When you perform a SetPaletteEntry, the entry is marked as
  27337. having changed, but no change occurs in the color environment.  The change will be
  27338. effected upon the next call to ActivatePalette.  Modified entries are marked such
  27339. that the palette will be updated even though no update might be required by a change
  27340. in the color environment.
  27341.  
  27342. æKY SetEntryUsage
  27343. æFp Palettes.p
  27344. æT PROCEDURE
  27345. æTN $AA9E
  27346. æD PROCEDURE SetEntryUsage(dstPalette: PaletteHandle;dstEntry: INTEGER;
  27347.     srcUsage: INTEGER;srcTolerance: INTEGER);
  27348. æDT SetEntryUsage(dstPalette,dstEntry,srcUsage,srcTolerance);
  27349. æRI SetEntryUsage procedure  V-165
  27350. æC 
  27351. SetEntryUsage provides a convenient way for your application to modify the color of a
  27352. single palette entry.  When you perform a SetEntryUsage, the entry is marked as
  27353. having changed, but no change occurs in the color environment.  The change will be
  27354. effected upon the next call to ActivatePalette.  Modified entries are marked such
  27355. that the palette will be updated even though no update might be required by a change
  27356. in the color environment.  If either myUsage or myTolerance are set to $FFFF (–1)
  27357. they will not be changed.
  27358.  
  27359. This call is provided to allow easy modifications to a palette created with NewPalette
  27360. or modified by CTab2Palette.  In such cases the ciUsage and ciTolerance fields are
  27361. homogeneous since only one value can be designated for each.  You will typically call
  27362. SetEntryUsage after those calls in order to adjust and customize your palette.
  27363.  
  27364. æKY SetPalette
  27365. æFp Palettes.p
  27366. æT PROCEDURE
  27367. æTN $AA95
  27368. æD PROCEDURE SetPalette(dstWindow: WindowPtr;srcPalette: PaletteHandle;
  27369.     cUpdates: BOOLEAN);
  27370. æDT SetPalette(dstWindow,srcPalette,cUpdates);
  27371. æRT 211
  27372. æRI SetPalette procedure  V-162
  27373. æC 
  27374. SetPalette changes the palette associated with dstWindow to srcPalette.  It also
  27375. records whether the window wants to receive updates as a result of a change to its
  27376. color environment.  If you want dstWindow to be updated whenever its color environment
  27377. changes, set cUpdates to TRUE.
  27378.  
  27379. æKY Perf.p
  27380. æKL InitPerf
  27381. PerfControl
  27382. PerfDump
  27383. TermPerf
  27384.  
  27385. AInts
  27386. ALongs
  27387. HInts
  27388. PInts
  27389. PLongs
  27390. TP2PerfGlobals
  27391. TPerfGlobals
  27392.  
  27393.  
  27394. æKY HInts,PInts,AInts
  27395. æFp Perf.p
  27396. æT TYPE
  27397. æC PInts = ^AInts;
  27398. HInts = ^PInts;
  27399. AInts = ARRAY [1..8000] OF INTEGER;
  27400.  
  27401. { PerfGlobals are declared as a record, so main program can allocate
  27402. as globals, desk accessory can add to globals allocated via pointer,
  27403. print driver can allocate via low memory, etc. }
  27404.  
  27405. æKY PLongs,ALongs
  27406. æFp Perf.p
  27407. æT TYPE
  27408. æC PLongs = ^ALongs;
  27409. ALongs = ARRAY [1..8000] OF LONGINT;
  27410.  
  27411. æKY TP2PerfGlobals,TPerfGlobals
  27412. æFp Perf.p
  27413. æT TYPE
  27414. æC TP2PerfGlobals = ^TPerfGlobals;
  27415. TPerfGlobals = RECORD
  27416.    startROM: LONGINT;          {ROM Base}
  27417.    romHits: LONGINT;           {used if MeasureROM is false}
  27418.    misses: LONGINT;            {count of PC values outside measured memory}
  27419.    segArray: PLongs;           {array of segment handles}
  27420.    sizeArray: PLongs;          {array of segment sizes}
  27421.    idArray: HInts;             {array of segment rsrc IDs}
  27422.    baseArray: PLongs;          {array of offsets to counters for each segment}
  27423.    samples: PLongs;            {samples buffer}
  27424.    buffSize: LONGINT;          {size of samples buffer in bytes}
  27425.    timeInterval: INTEGER;      {number of clock intervals between interrupts}
  27426.    bucketSize: INTEGER;        {size of buckets power of 2}
  27427.    log2buckSize: INTEGER;      {used in CvtPC}
  27428.    pcOffset: INTEGER;          {offset to the user PC at interrupt time.}
  27429.    numMeasure: INTEGER;        {# Code segments (w/o jump table)- ROM etc.}
  27430.    firstCode: INTEGER;         {index of first Code segment}
  27431.    takingSamples: BOOLEAN;     {true if sampling is enabled}
  27432.    measureROM: BOOLEAN;
  27433.    measureCode: BOOLEAN;
  27434.    ramSeg: INTEGER;            {index of "segment" record to cover RAM > 0 if RAM 
  27435.                                 (misses) are to be bucketed.}
  27436.    ramBase: LONGINT;           {beginning of RAM being measured.}
  27437.    measureRAMbucketSize: INTEGER;
  27438.    measureRAMlog2buckSize: INTEGER;
  27439.    romVersion: INTEGER;
  27440.    vRefNum: INTEGER;           {Volume where the report file is to be created}
  27441.    volumeSelected: BOOLEAN;    {True if user selects the report file name}
  27442.    rptFileName: Str255;        {Report file name}
  27443.    rptFileCreator: Str255;     {Report File Creator}
  27444.    rptFileType: Str255;        {Report File type}
  27445.    getResType: ResType;        {Resource type}
  27446.    END;
  27447.  
  27448. æKY InitPerf
  27449. æFp Perf.p
  27450. æT FUNCTION
  27451. æD FUNCTION InitPerf(VAR thePerfGlobals: TP2PerfGlobals;timerCount: INTEGER;
  27452.     codeAndROMBucketSize: INTEGER;doROM: BOOLEAN;doAppCode: BOOLEAN;appCodeType: Str255;
  27453.     romID: INTEGER;romName: Str255;doRAM: BOOLEAN;ramLow: LONGINT;ramHigh: LONGINT;
  27454.     ramBucketSize: INTEGER): BOOLEAN;
  27455. æDT myVariable := InitPerf(thePerfGlobals,timerCount,codeAndROMBucketSize,
  27456.     doROM,doAppCode,appCodeType,romID,romName,doRAM,ramLow,ramHigh,ramBucketSize);
  27457. æC 
  27458. called once to setup Performance monitoring
  27459.  
  27460. æKY PerfControl
  27461. æFp Perf.p
  27462. æT FUNCTION
  27463. æD FUNCTION PerfControl(thePerfGlobals: TP2PerfGlobals;turnOn: BOOLEAN): BOOLEAN;
  27464. æDT myVariable := PerfControl(thePerfGlobals,turnOn);
  27465. æC  Call this to turn off/on measuring.
  27466.      Returns previous state.
  27467.  
  27468. æKY PerfDump
  27469. æFp Perf.p
  27470. æT FUNCTION
  27471. æD FUNCTION PerfDump(thePerfGlobals: TP2PerfGlobals;reportFile: Str255;
  27472.     doHistogram: BOOLEAN;rptFileColumns: INTEGER): INTEGER;
  27473. æDT myVariable := PerfDump(thePerfGlobals,reportFile,doHistogram,rptFileColumns);
  27474. æC 
  27475. Call this to dump the statistics into a file.
  27476.  
  27477. æKY TermPerf
  27478. æFp Perf.p
  27479. æT PROCEDURE
  27480. æD PROCEDURE TermPerf(thePerfGlobals: TP2PerfGlobals);
  27481. æDT TermPerf(thePerfGlobals);
  27482. æC 
  27483. if InitPerf succeeds then TermPerf must be called before terminating program.
  27484.  
  27485. æKY Picker.p
  27486. æKL CMY2RGB
  27487. Fix2SmallFract
  27488. GetColor
  27489. HSL2RGB
  27490. HSV2RGB
  27491. RGB2CMY
  27492. RGB2HSL
  27493. RGB2HSV
  27494. SmallFract2Fix
  27495.  
  27496. CMYColor
  27497. HSLColor
  27498. HSVColor
  27499. MaxSmallFract
  27500. SmallFract
  27501.  
  27502.  
  27503. æKY CMY2RGB
  27504. æFp Picker.p
  27505. æT PROCEDURE
  27506. æTN $A82E
  27507. æD PROCEDURE CMY2RGB(cColor: CMYColor;VAR rColor: RGBColor);
  27508. æDT CMY2RGB(cColor,rColor);
  27509. æMM   
  27510. æC 
  27511. The Color Picker provides six procedures for converting color values between CMY and
  27512. RGB, and between HSL or HSV and RGB.  Most developers will not need to use these
  27513. routines.
  27514.  
  27515. PROCEDURE  CMY2RGB (cColor: CMYColor; VAR rColor: RGBColor);
  27516. PROCEDURE  RGB2CMY (rColor: RGBColor; VAR cColor: CMYColor);
  27517. PROCEDURE  HSL2RGB (hColor: HSLColor; VAR rColor: RGBColor);
  27518. PROCEDURE  RGB2HSL (rColor: RGBColor; VAR hColor: HSLColor);
  27519. PROCEDURE  HSV2RGB (hColor: HSVColor; VAR rColor: RGBColor);
  27520. PROCEDURE  RGB2HSV (rColor: RGBColor; VAR hColor: HSVColor);
  27521.  
  27522. For developmental simplicity in switching between the HLS and HSV models, HLS is
  27523. reordered into HSL. Thus both models start with hue and saturation values; value/lightness/brightness
  27524. is last.
  27525.  
  27526. The CMY, HSL, and HSV structures are defined by ColorPicker with SmallFract values
  27527. rather than INTEGER values (as in RGBColor).  A SmallFract value is the fractional
  27528. part of a Fixed number, which is the low-order word.  The INTEGER values in RGBColor
  27529. are actually used as unsigned integer-sized values; by using SmallFracts, ColorPicker
  27530. avoids sign extension problems in the conversion math.
  27531.  
  27532. æKY CMYColor
  27533. æFp Picker.p
  27534. æT RECORD
  27535. æC CMYColor = RECORD
  27536.    cyan: SmallFract;
  27537.    magenta: SmallFract;
  27538.    yellow: SmallFract;
  27539.    END;
  27540.  
  27541. æKY Fix2SmallFract
  27542. æFp Picker.p
  27543. æT FUNCTION
  27544. æTN $A82E
  27545. æD FUNCTION Fix2SmallFract(f: Fixed): SmallFract;
  27546. æDT myVariable := Fix2SmallFract(f);
  27547. æMM   
  27548. æRI Fix2SmallFract function  V-175
  27549. æC 
  27550. The Color Picker provides two functions for converting between SmallFract and Fixed
  27551. numbers.  Most developers will not need to use these facilities.
  27552.  
  27553. FUNCTION Fix2SmallFract(f: Fixed): SmallFract;
  27554. FUNCTION SmallFract2Fix(s: SmallFract): Fixed;
  27555.  
  27556. A SmallFract can represent a value between 0 and  65,535.  They can be assigned
  27557. directly to and from INTEGERs.
  27558.  
  27559. æKY GetColor
  27560. æFp Picker.p
  27561. æT FUNCTION
  27562. æTN $A82E
  27563. æD FUNCTION GetColor(where: Point;prompt: Str255;inColor: RGBColor;VAR outColor: RGBColor): BOOLEAN;
  27564. æDT myVariable := GetColor(where,prompt,inColor,outColor);
  27565. æMM   
  27566. æRI GetColor function  V-174
  27567. æC 
  27568. GetColor displays the Color Picker dialog box on the screen, with its top-left corner
  27569. located at where. (The where Point should be on the main gDevice.)  If where = (0,0),
  27570. the dialog box is positioned neatly on the screen, centered horizontally, and with
  27571. one third of the empty space above the box, two thirds below, whatever the screen
  27572. size.
  27573.  
  27574. The prompt string is displayed in the upper-left corner of the dialog box.  InColor
  27575. is the starting color, which the user may want for comparison, and is displayed
  27576. immediately below the current output color (the one the user is picking).  OutColor
  27577. is set to the last color value the user picked, if and only if the user clicks OK.  
  27578. On entry, it is treated as undefined, so the output color sample originally matches
  27579. the input.  While the color being picked may vary widely, the input color sample
  27580. remains fixed, and clicking in the input sample resets the output color sample to
  27581. match it.
  27582.  
  27583. GetColor returns TRUE if the user exits via the OK button, or FALSE if the user
  27584. cancels.
  27585.  
  27586. Assembly-language note:  the trap macro for the Color Picker Package is
  27587.                          _Pack12. The routine selectors are as follows:
  27588.  
  27589.                            Fix2SmallFract  .EQU    1
  27590.                            SmallFract2Fix  .EQU    2
  27591.                            CMY2RGB         .EQU    3
  27592.                            RGB2CMY         .EQU    4
  27593.                            HSL2RGB         .EQU    5
  27594.                            RGB2HSL         .EQU    6
  27595.                            HSV2RGB         .EQU    7
  27596.                            RGB2HSV         .EQU    8
  27597.                            GetColor        .EQU    9
  27598.  
  27599. æKY HSL2RGB
  27600. æFp Picker.p
  27601. æT PROCEDURE
  27602. æTN $A82E
  27603. æD PROCEDURE HSL2RGB(hColor: HSLColor;VAR rColor: RGBColor);
  27604. æDT HSL2RGB(hColor,rColor);
  27605. æMM   
  27606. æRI HSL2RGB procedure  V-175
  27607. æC 
  27608. The Color Picker provides six procedures for converting color values between CMY and
  27609. RGB, and between HSL or HSV and RGB.  Most developers will not need to use these
  27610. routines.
  27611.  
  27612. PROCEDURE  CMY2RGB (cColor: CMYColor; VAR rColor: RGBColor);
  27613. PROCEDURE  RGB2CMY (rColor: RGBColor; VAR cColor: CMYColor);
  27614. PROCEDURE  HSL2RGB (hColor: HSLColor; VAR rColor: RGBColor);
  27615. PROCEDURE  RGB2HSL (rColor: RGBColor; VAR hColor: HSLColor);
  27616. PROCEDURE  HSV2RGB (hColor: HSVColor; VAR rColor: RGBColor);
  27617. PROCEDURE  RGB2HSV (rColor: RGBColor; VAR hColor: HSVColor);
  27618.  
  27619. For developmental simplicity in switching between the HLS and HSV models, HLS is
  27620. reordered into HSL. Thus both models start with hue and saturation values; value/lightness/brightness
  27621. is last.
  27622.  
  27623. The CMY, HSL, and HSV structures are defined by ColorPicker with SmallFract values
  27624. rather than INTEGER values (as in RGBColor).  A SmallFract value is the fractional
  27625. part of a Fixed number, which is the low-order word.  The INTEGER values in RGBColor
  27626. are actually used as unsigned integer-sized values; by using SmallFracts, ColorPicker
  27627. avoids sign extension problems in the conversion math.
  27628.  
  27629. æKY HSLColor
  27630. æFp Picker.p
  27631. æT RECORD
  27632. æC HSLColor = RECORD
  27633.    hue: SmallFract;            {Fraction of circle, red at 0}
  27634.    saturation: SmallFract;     {0-1, 0 for gray, 1 for pure color}
  27635.    lightness: SmallFract;      {0-1, 0 for black, 1 for white}
  27636.    END;
  27637.  
  27638. æKY HSV2RGB
  27639. æFp Picker.p
  27640. æT PROCEDURE
  27641. æTN $A82E
  27642. æD PROCEDURE HSV2RGB(hColor: HSVColor;VAR rColor: RGBColor);
  27643. æDT HSV2RGB(hColor,rColor);
  27644. æMM   
  27645. æRI HSV2RGB procedure  V-175
  27646. æC 
  27647. The Color Picker provides six procedures for converting color values between CMY and
  27648. RGB, and between HSL or HSV and RGB.  Most developers will not need to use these
  27649. routines.
  27650.  
  27651. PROCEDURE  CMY2RGB (cColor: CMYColor; VAR rColor: RGBColor);
  27652. PROCEDURE  RGB2CMY (rColor: RGBColor; VAR cColor: CMYColor);
  27653. PROCEDURE  HSL2RGB (hColor: HSLColor; VAR rColor: RGBColor);
  27654. PROCEDURE  RGB2HSL (rColor: RGBColor; VAR hColor: HSLColor);
  27655. PROCEDURE  HSV2RGB (hColor: HSVColor; VAR rColor: RGBColor);
  27656. PROCEDURE  RGB2HSV (rColor: RGBColor; VAR hColor: HSVColor);
  27657.  
  27658. For developmental simplicity in switching between the HLS and HSV models, HLS is
  27659. reordered into HSL. Thus both models start with hue and saturation values; value/lightness/brightness
  27660. is last.
  27661.  
  27662. The CMY, HSL, and HSV structures are defined by ColorPicker with SmallFract values
  27663. rather than INTEGER values (as in RGBColor).  A SmallFract value is the fractional
  27664. part of a Fixed number, which is the low-order word.  The INTEGER values in RGBColor
  27665. are actually used as unsigned integer-sized values; by using SmallFracts, ColorPicker
  27666. avoids sign extension problems in the conversion math.
  27667.  
  27668. æKY HSVColor
  27669. æFp Picker.p
  27670. æT RECORD
  27671. æC HSVColor = RECORD
  27672.    hue: SmallFract;            {Fraction of circle, red at 0}
  27673.    saturation: SmallFract;     {0-1, 0 for gray, 1 for pure color}
  27674.    value: SmallFract;          {0-1, 0 for black, 1 for max intensity}
  27675.    END;
  27676.  
  27677. æKY MaxSmallFract
  27678. æFp Picker.p
  27679. æC MaxSmallFract = $0000FFFF; {Maximum small fract value, as long}
  27680.  
  27681. æKY RGB2CMY
  27682. æFp Picker.p
  27683. æT PROCEDURE
  27684. æTN $A82E
  27685. æD PROCEDURE RGB2CMY(rColor: RGBColor;VAR cColor: CMYColor);
  27686. æDT RGB2CMY(rColor,cColor);
  27687. æMM   
  27688. æRI RGB2CMY procedure  V-175
  27689. æC 
  27690. The Color Picker provides six procedures for converting color values between CMY and
  27691. RGB, and between HSL or HSV and RGB.  Most developers will not need to use these
  27692. routines.
  27693.  
  27694. PROCEDURE  CMY2RGB (cColor: CMYColor; VAR rColor: RGBColor);
  27695. PROCEDURE  RGB2CMY (rColor: RGBColor; VAR cColor: CMYColor);
  27696. PROCEDURE  HSL2RGB (hColor: HSLColor; VAR rColor: RGBColor);
  27697. PROCEDURE  RGB2HSL (rColor: RGBColor; VAR hColor: HSLColor);
  27698. PROCEDURE  HSV2RGB (hColor: HSVColor; VAR rColor: RGBColor);
  27699. PROCEDURE  RGB2HSV (rColor: RGBColor; VAR hColor: HSVColor);
  27700.  
  27701. For developmental simplicity in switching between the HLS and HSV models, HLS is
  27702. reordered into HSL. Thus both models start with hue and saturation values; value/lightness/brightness
  27703. is last.
  27704.  
  27705. The CMY, HSL, and HSV structures are defined by ColorPicker with SmallFract values
  27706. rather than INTEGER values (as in RGBColor).  A SmallFract value is the fractional
  27707. part of a Fixed number, which is the low-order word.  The INTEGER values in RGBColor
  27708. are actually used as unsigned integer-sized values; by using SmallFracts, ColorPicker
  27709. avoids sign extension problems in the conversion math.
  27710.  
  27711. æKY RGB2HSL
  27712. æFp Picker.p
  27713. æT PROCEDURE
  27714. æTN $A82E
  27715. æD PROCEDURE RGB2HSL(rColor: RGBColor;VAR hColor: HSLColor);
  27716. æDT RGB2HSL(rColor,hColor);
  27717. æMM   
  27718. æRI RGB2HSL procedure  V-175
  27719. æC 
  27720. The Color Picker provides six procedures for converting color values between CMY and
  27721. RGB, and between HSL or HSV and RGB.  Most developers will not need to use these
  27722. routines.
  27723.  
  27724. PROCEDURE  CMY2RGB (cColor: CMYColor; VAR rColor: RGBColor);
  27725. PROCEDURE  RGB2CMY (rColor: RGBColor; VAR cColor: CMYColor);
  27726. PROCEDURE  HSL2RGB (hColor: HSLColor; VAR rColor: RGBColor);
  27727. PROCEDURE  RGB2HSL (rColor: RGBColor; VAR hColor: HSLColor);
  27728. PROCEDURE  HSV2RGB (hColor: HSVColor; VAR rColor: RGBColor);
  27729. PROCEDURE  RGB2HSV (rColor: RGBColor; VAR hColor: HSVColor);
  27730.  
  27731. For developmental simplicity in switching between the HLS and HSV models, HLS is
  27732. reordered into HSL. Thus both models start with hue and saturation values; value/lightness/brightness
  27733. is last.
  27734.  
  27735. The CMY, HSL, and HSV structures are defined by ColorPicker with SmallFract values
  27736. rather than INTEGER values (as in RGBColor).  A SmallFract value is the fractional
  27737. part of a Fixed number, which is the low-order word.  The INTEGER values in RGBColor
  27738. are actually used as unsigned integer-sized values; by using SmallFracts, ColorPicker
  27739. avoids sign extension problems in the conversion math.
  27740.  
  27741. æKY RGB2HSV
  27742. æFp Picker.p
  27743. æT PROCEDURE
  27744. æTN $A82E
  27745. æD PROCEDURE RGB2HSV(rColor: RGBColor;VAR hColor: HSVColor);
  27746. æDT RGB2HSV(rColor,hColor);
  27747. æMM   
  27748. æRI RGB2HSV procedure  V-175
  27749. æC 
  27750. The Color Picker provides six procedures for converting color values between CMY and
  27751. RGB, and between HSL or HSV and RGB.  Most developers will not need to use these
  27752. routines.
  27753.  
  27754. PROCEDURE  CMY2RGB (cColor: CMYColor; VAR rColor: RGBColor);
  27755. PROCEDURE  RGB2CMY (rColor: RGBColor; VAR cColor: CMYColor);
  27756. PROCEDURE  HSL2RGB (hColor: HSLColor; VAR rColor: RGBColor);
  27757. PROCEDURE  RGB2HSL (rColor: RGBColor; VAR hColor: HSLColor);
  27758. PROCEDURE  HSV2RGB (hColor: HSVColor; VAR rColor: RGBColor);
  27759. PROCEDURE  RGB2HSV (rColor: RGBColor; VAR hColor: HSVColor);
  27760.  
  27761. For developmental simplicity in switching between the HLS and HSV models, HLS is
  27762. reordered into HSL. Thus both models start with hue and saturation values; value/lightness/brightness
  27763. is last.
  27764.  
  27765. The CMY, HSL, and HSV structures are defined by ColorPicker with SmallFract values
  27766. rather than INTEGER values (as in RGBColor).  A SmallFract value is the fractional
  27767. part of a Fixed number, which is the low-order word.  The INTEGER values in RGBColor
  27768. are actually used as unsigned integer-sized values; by using SmallFracts, ColorPicker
  27769. avoids sign extension problems in the conversion math.
  27770.  
  27771. æKY SmallFract
  27772. æFp Picker.p
  27773. æT TYPE
  27774. æC SmallFract = INTEGER;
  27775.  
  27776. æKY SmallFract2Fix
  27777. æFp Picker.p
  27778. æT FUNCTION
  27779. æTN $A82E
  27780. æD FUNCTION SmallFract2Fix(s: SmallFract): Fixed;
  27781. æDT myVariable := SmallFract2Fix(s);
  27782. æMM   
  27783. æRI SmallFract2Fix function  V-175
  27784. æC 
  27785. The Color Picker provides two functions for converting between SmallFract and Fixed
  27786. numbers.  Most developers will not need to use these facilities.
  27787.  
  27788. FUNCTION Fix2SmallFract(f: Fixed): SmallFract;
  27789. FUNCTION SmallFract2Fix(s: SmallFract): Fixed;
  27790.  
  27791. A SmallFract can represent a value between 0 and  65,535.  They can be assigned
  27792. directly to and from INTEGERs.
  27793.  
  27794.  
  27795. æKY Printing.p
  27796. æKL PrClose
  27797. PrCloseDoc
  27798. PrClosePage
  27799. PrCtlCall
  27800. PrDlgMain
  27801. PrDrvrClose
  27802. PrDrvrDCE
  27803. PrDrvrOpen
  27804. PrDrvrVers
  27805. PrError
  27806. PrGeneral
  27807. PrintDefault
  27808. PrJobDialog
  27809. PrJobInit
  27810. PrJobMerge
  27811. PrNoPurge
  27812. PrOpen
  27813. PrOpenDoc
  27814. PrOpenPage
  27815. PrPicFile
  27816. PrPurge
  27817. PrSetError
  27818. PrStlDialog
  27819. PrStlInit
  27820. PrValidate
  27821.  
  27822. bDraftLoop
  27823. bSpoolLoop
  27824. bUser1Loop
  27825. bUser2Loop
  27826. draftBitsOp
  27827. feedCut
  27828. feedFanfold
  27829. feedMechCut
  27830. feedOther
  27831. fHiResOK
  27832. fNewRunBit
  27833. fWeOpenedRF
  27834. getRotnOp
  27835. getRslDataOp
  27836. iFMgrCtl
  27837. iIOAbort
  27838. iMemFullErr
  27839. iMscCtl
  27840. invalColReq
  27841. iPFMaxPgs
  27842. iPrAbort
  27843. iPrBitsCtl
  27844. iPrDevCtl
  27845. iPrDrvrRef
  27846. iPrEvtCtl
  27847. iPrIOCtl
  27848. iPrPgFract
  27849. iPrPgFst
  27850. iPrPgMax
  27851. iPrRelease
  27852. iPrSavPFil
  27853. iPvtCtl
  27854. lHiPaintBits
  27855. lHiScreenBits
  27856. lPaintBits
  27857. lPrDocClose
  27858. lPrDocOpen
  27859. lPrEvtAll
  27860. lPrEvtTop
  27861. lPrLFSixth
  27862. lPrLFStd
  27863. lPrLineFeed
  27864. lPrPageClose
  27865. lPrPageEnd
  27866. lPrPageOpen
  27867. lPrReset
  27868. lScreenBits
  27869. noDraftBitsOp
  27870. NoSuchRsl
  27871. pPrGlobals
  27872. Rect
  27873. RgType1
  27874. scanBT
  27875. scanLR
  27876. scanRL
  27877. scanTB
  27878. setRslOp
  27879. TDftBitsBlk
  27880. TFeed
  27881. TGetRotnBlk
  27882. TGetRslBlk
  27883. TGnlData
  27884. THLong
  27885. THPfPgDir
  27886. THPrint
  27887. THWord
  27888. TLong
  27889. TPfPgDir
  27890. TPLong
  27891. TPPfPgDir
  27892. TPPrDlg
  27893. TPPrInfo
  27894. TPPrint
  27895. TPPrJob
  27896. TPPrPort
  27897. TPPrStatus
  27898. TPPrStl
  27899. TPPrXInfo
  27900. TPrDlg
  27901. TPRect
  27902. TPrInfo
  27903. TPrint
  27904. TPrJob
  27905. TPrPort
  27906. TPrStatus
  27907. TPrStl
  27908. TPrXInfo
  27909. TPWord
  27910. TRslRec
  27911. TRslRg
  27912. TScan
  27913. TSetRslBlk
  27914. TWord
  27915.  
  27916. æKY THLong,TPLong,TLong
  27917. æFp Printing.p
  27918. æT TYPE
  27919. æC TPLong = ^TLong;
  27920. THLong = ^TPLong;
  27921. TLong = RECORD
  27922.     CASE INTEGER OF
  27923.       0:
  27924.         (w1,w0: TWord);
  27925.      1:
  27926.         (b1,b0: LONGINT);
  27927.       2:
  27928.         (p0: Ptr);
  27929.       3:
  27930.         (h0: Handle);
  27931.       4:
  27932.         (pt: Point);
  27933.     END;
  27934.  
  27935. æKY THPfPgDir,TPPfPgDir,TPfPgDir
  27936. æFp Printing.p
  27937. æT TYPE
  27938. æC TPPfPgDir = ^TPfPgDir;
  27939. THPfPgDir = ^TPPfPgDir;
  27940. TPfPgDir = RECORD
  27941.    iPages: INTEGER;
  27942.    iPgPos: ARRAY [0..128] OF LONGINT;  {ARRAY [0..iPfMaxPgs] OF LONGINT}
  27943.    END;
  27944.  
  27945. æKY TPrint,TPPrint,THPrint
  27946. æFp Printing.p
  27947. æT TYPE
  27948. æC TPPrint = ^TPrint;
  27949. THPrint = ^TPPrint;
  27950. TPrint = RECORD
  27951.    iPrVersion: INTEGER;                {(2) Printing software version}
  27952.    prInfo: TPrInfo;                    {(14) the PrInfo data associated with the 
  27953.                                         current style.}
  27954.    rPaper: Rect;                       {(8) The paper rectangle [offset from rPage]}
  27955.    prStl: TPrStl;                      {(8)  This print request's style.}
  27956.    prInfoPT: TPrInfo;                  {(14)  Print Time Imaging metrics}
  27957.    prXInfo: TPrXInfo;                  {(16)  Print-time (expanded) Print info record.}
  27958.    prJob: TPrJob;                      {(20) The Print Job request (82)  Total of the 
  27959.                                         above; 120-82 = 38 bytes needed to fill 120}
  27960.    printX: ARRAY [1..19] OF INTEGER;   {Spare to fill to 120 bytes!}
  27961.    END;
  27962.  
  27963. Print records are referred to by handles. Their structure is as follows:
  27964.  
  27965. TYPE  THPrint = ^TPPrint;
  27966.       TPPrint = ^TPrint;
  27967.       TPrint  = RECORD
  27968.                    iPrVersion:  INTEGER;  {Printing Manager version}
  27969.                    prInfo:      TPrInfo;  {printer information subrecord}
  27970.                    rPaper:      Rect;     {paper rectangle}
  27971.                    prStl:       TPrStl;   {additional device information}
  27972.                    prInfoPT:    TPrInfo;  {used internally}
  27973.                    prXInfo:     TPrXInfo; {additional device information}
  27974.                    prJob:       TPrJob;   {job subrecord}
  27975.                    printX:      ARRAY[1..19] OF INTEGER {not used}
  27976.                  END;
  27977.  
  27978. Warning:  Your application should not change the data in the print record—be
  27979.           sure to use the standard dialogs for setting this information. The
  27980.           only fields you’ll need to set directly are some containing optional
  27981.           information in the job subrecord (explained below). Attempting to set
  27982.           other values directly in the print record can produce unexpected
  27983.          results.
  27984.  
  27985. IPrVersion identifies the version of the Printing Manager that initialized this print
  27986. record. If you try to use a print record that’s invalid for the current version of
  27987. the Printing Manager or for the currently installed printer, the Printing Manager
  27988. will correct the record by filling it with default values.
  27989.  
  27990. The other fields of the print record are discussed in separate sections below.
  27991.  
  27992. Note:  Whenever you save a document, you should write an appropriate print
  27993.        record in the document’s resource file. This lets the document
  27994.        “remember” its own printing parameters for use the next time it’s
  27995.        printed.
  27996.  
  27997. æKY THWord,TPWord,TWord
  27998. æFp Printing.p
  27999. æT TYPE
  28000. æC TPWord = ^TWord;
  28001. THWord = ^TPWord;
  28002. TWord = PACKED RECORD
  28003.    CASE INTEGER OF
  28004.      0:
  28005.        (c1,c0: CHAR);
  28006.      1:
  28007.        (b1,b0: SignedByte);
  28008.      2:
  28009.        (usb1,usb0: Byte);
  28010.      3:
  28011.        (n3,n2,n1,n0: TN);
  28012.      4:
  28013.        (f15,f14,f13,f12,f11,f10,f9,f8,f7,f6,f5,f4,f3,f2,f1,f0: BOOLEAN);
  28014.      5:
  28015.        (i0: INTEGER);
  28016.    END;
  28017.  
  28018. æKY TPPrDlg,TPrDlg
  28019. æFp Printing.p
  28020. æT TYPE
  28021. æC TPPrDlg = ^TPrDlg;
  28022. TPrDlg = RECORD
  28023.    Dlg: DialogRecord;                  {The Dialog window}
  28024.    pFltrProc: ProcPtr;                 {The Filter Proc.}
  28025.    pItemProc: ProcPtr;                 {The Item evaluating proc.}
  28026.    hPrintUsr: THPrint;                 {The user's print record.}
  28027.    fDoIt: BOOLEAN;
  28028.    fDone: BOOLEAN;
  28029.    lUser1: LONGINT;                    {Four longs for user's to hang global data.}
  28030.    lUser2: LONGINT;                    {...Plus more stuff needed by the particular 
  28031.                                         printing dialog.}
  28032.    lUser3: LONGINT;
  28033.    lUser4: LONGINT;
  28034.    END;
  28035.  
  28036. æKY TPrInfo,TPPrInfo
  28037. æFp Printing.p
  28038. æT TYPE
  28039. æC TPPrInfo = ^TPrInfo;
  28040. TPrInfo = RECORD
  28041.    iDev: INTEGER;                      {Font mgr/QuickDraw device code}
  28042.    iVRes: INTEGER;                     {Resolution of device, in device coordinates}
  28043.    iHRes: INTEGER;                     {..note: V before H => compatable with Point.}
  28044.    rPage: Rect;                        {The page (printable) rectangle in device 
  28045.                                         coordinates.}
  28046.    END;
  28047.  
  28048. »The Printer Information Subrecord
  28049.  
  28050. The printer information subrecord (field prInfo of the print record) gives you the
  28051. information needed for page composition. It’s defined as follows:
  28052.  
  28053. TYPE  TPrInfo = RECORD
  28054.                   iDev:   INTEGER;  {used internally}
  28055.                   iVRes:  INTEGER;  {vertical resolution of printer}
  28056.                   iHRes:  INTEGER;  {horizontal resolution of printer}
  28057.                   rPage:  Rect      {page rectangle}
  28058.                 END;
  28059.  
  28060. RPage is the page rectangle, representing the boundaries of the printable page:  The
  28061. printing grafPort’s boundary rectangle, portRect, and clipRgn are set to this rectangle.
  28062. Its top left corner always has coordinates (0,0); the coordinates of the bottom right
  28063. corner give the maximum page height and width attainable on the given printer, in
  28064. dots. Typically these are slightly less than the physical dimensions of the paper,
  28065. because of the printer’s mechanical limitations. RPage is set as a result of the
  28066. style dialog.
  28067.  
  28068. The rPage rectangle is inside the paper rectangle, specified by the rPaper field of
  28069. the print record. RPaper gives the physical paper size, defined in the same coordinate
  28070. system as rPage (see Figure 4). Thus the top left coordinates of the paper rectangle
  28071. are typically negative and its bottom right coordinates are greater than those of the
  28072. page rectangle.
  28073.  
  28074. IVRes and iHRes give the printer’s vertical and horizontal resolution in dots per
  28075. inch. Thus, if you divide the width of rPage by iHRes, you get the width of the page
  28076. rectangle in inches.
  28077.  
  28078. æKY TPrJob,TPPrJob
  28079. æFp Printing.p
  28080. æT TYPE
  28081. æC TPPrJob = ^TPrJob;
  28082. TPrJob = RECORD
  28083.    iFstPage: INTEGER;                  {Page Range.}
  28084.    iLstPage: INTEGER;
  28085.    iCopies: INTEGER;                   {No. copies.}
  28086.    bJDocLoop: SignedByte;              {The Doc style: Draft, Spool, .., and ..}
  28087.    fFromUsr: BOOLEAN;                  {Printing from an User's App (not PrApp) flag}
  28088.    pIdleProc: ProcPtr;                 {The Proc called while waiting on IO etc.}
  28089.    pFileName: StringPtr;               {Spool File Name: NIL for default.}
  28090.    iFileVol: INTEGER;                  {Spool File vol, set to 0 initially}
  28091.    bFileVers: SignedByte;              {Spool File version, set to 0 initially}
  28092.    bJobX: SignedByte;                  {An eXtra byte.}
  28093.    END;
  28094.  
  28095. »The Job Subrecord
  28096.  
  28097. The job subrecord (field prJob of the print record) contains information about a
  28098. particular printing job. Its contents are set as a result of the job dialog.
  28099.  
  28100. •••Refer to Figure 4.•••
  28101.  
  28102. Figure 4–Page and Paper Rectangles
  28103.  
  28104. The job subrecord is defined as follows:
  28105.  
  28106. TYPE TPrJob = RECORD
  28107.                 iFstPage:   INTEGER;     {first page to print}
  28108.                 iLstPage:   INTEGER;     {last page to print}
  28109.                 iCopies:    INTEGER;     {number of copies}
  28110.                 bJDocLoop:  SignedByte;  {printing method}
  28111.                 fFromUsr:   BOOLEAN;     {used internally}
  28112.                 pIdleProc:  ProcPtr;     {background procedure}
  28113.                 pFileName:  StringPtr;   {spool file name}
  28114.                 iFileVol:   INTEGER;     {spool file volume reference number}
  28115.                 bFileVers:  SignedByte;  {spool file version number}
  28116.                 bJobX:      SignedByte   {used internally}
  28117.               END;
  28118.  
  28119. BJDocLoop designates the printing method that the Printing Manager will use. It will
  28120. be one of the following predefined constants:
  28121.  
  28122. CONST  bDraftLoop = 0;    {draft printing}
  28123.        bSpoolLoop = 1;    {spool printing}
  28124.  
  28125. Draft printing means that the document will be printed immediately. Spool printing
  28126. means that printing may be deferred:  The Printing Manager writes out a representation
  28127. of the document’s printed image to a disk file (or possibly to memory); this information
  28128. is then converted into a bit image and printed. For details about the printing methods,
  28129. see the “Methods of Printing” section below. The Printing Manager sets the bJDocLoop
  28130. field; your application should not change it.
  28131.  
  28132. IFstPage and iLstPage designate the first and last pages to be printed. These page
  28133. numbers are relative to the first page counted by the Printing Manager. The Printing
  28134. Manager knows nothing about any page numbering placed by an application within a
  28135. document.
  28136.  
  28137. ICopies is the number of copies to print. The Printing Manager automatically handles
  28138. multiple copies for spool printing or for printing on the LaserWriter. Your application
  28139. only needs this number for draft printing on the Imagewriter.
  28140.  
  28141. PIdleProc is a pointer to the background procedure (explained below) for this printing
  28142. operation. In a newly initialized print record this field is set to NIL, designating
  28143. the default background procedure, which just polls the keyboard and cancels further
  28144. printing if the user types Command-period. You can install a background procedure of
  28145. your own by storing a pointer to your procedure directly into the pIdleProc field.
  28146.  
  28147. For spool printing, your application may optionally provide a spool file name, volume
  28148. reference number, and version number (described in the File Manager chapter):
  28149.  
  28150.   •  PFileName is the name of the spool file. This field is initialized to
  28151.      NIL, and generally not changed by the application. NIL denotes the
  28152.      default file name (normally 'Print File') stored in the printer resource
  28153.      file.
  28154.   •  IFileVol is the volume reference number of the spool file. This field
  28155.      is initialized to 0, representing the default volume. You can use the
  28156.      File Manager function SetVol to change the default volume, or you can
  28157.      override the default setting by storing directly into this field.
  28158.   •  BFileVers is the version number of the spool file, initialized to 0.
  28159.  
  28160. æKY TPPrPort,TPrPort
  28161. æFp Printing.p
  28162. æT TYPE
  28163. æC TPPrPort = ^TPrPort;
  28164. TPrPort = RECORD
  28165.    gPort: GrafPort;                    {The Printer's graf port.}
  28166.    gProcs: QDProcs;                    {..and its procs}
  28167.    lGParam1: LONGINT;                  {16 bytes for private parameter storage.}
  28168.    lGParam2: LONGINT;
  28169.    lGParam3: LONGINT;
  28170.    lGParam4: LONGINT;
  28171.    fOurPtr: BOOLEAN;                   {Whether the PrPort allocation was done by us.}
  28172.    fOurBits: BOOLEAN;                  {Whether the BitMap allocation was done by us.}
  28173.    END;
  28174.  
  28175. æKY TPrStatus,TPPrStatus
  28176. æFp Printing.p
  28177. æT TYPE
  28178. æC TPPrStatus = ^TPrStatus;
  28179. TPrStatus = RECORD
  28180.    iTotPages: INTEGER;                 {Total pages in Print File.}
  28181.    iCurPage: INTEGER;                  {Current page number}
  28182.    iTotCopies: INTEGER;                {Total copies requested}
  28183.    iCurCopy: INTEGER;                  {Current copy number}
  28184.    iTotBands: INTEGER;                 {Total bands per page.}
  28185.    iCurBand: INTEGER;                  {Current band number}
  28186.    fPgDirty: BOOLEAN;                  {True if current page has been written to.}
  28187.    fImaging: BOOLEAN;                  {Set while in band's DrawPic call.}
  28188.    hPrint: THPrint;                    {Handle to the active Printer record}
  28189.    pPrPort: TPPrPort;                  {Ptr to the active PrPort}
  28190.    hPic: PicHandle;                    {Handle to the active Picture}
  28191.    END;
  28192.  
  28193. The prStatus parameter is a printer status record that PrPicFile will use to report
  28194. on its progress:
  28195.  
  28196. TYPE  TPrStatus = RECORD
  28197.                     iTotPages:   INTEGER;    {number of pages in spool file}
  28198.                     iCurPage:    INTEGER;    {page being printed}
  28199.                     iTotCopies:  INTEGER;    {number of copies requested}
  28200.                     iCurCopy:    INTEGER;    {copy being printed}
  28201.                     iTotBands:   INTEGER;    {used internally}
  28202.